views:

393

answers:

1

hi,

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?

thx

+2  A: 

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.

TM
great - thanks!
Fuxi