Question

How can I prevent the jQuery dialog from closing when I click the mouse? Closing on hitting esc is fine but I want to keep it open until I close it by clicking the close-icon.

Any ideas?

Was it helpful?

Solution

You can use the dialogbeforeclose event to pass a callback function that will be called whenever the dialog is about to close.

If you return false from this function, the close will be cancelled.

$('.selector').bind('dialogbeforeclose', function(event, ui) {
  ...
});

http://docs.jquery.com/UI/Dialog#event-beforeclose

You can do something like check the element that the event was fired from, and use that to determine whether or not the user clicked on the X to close or on something else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top