Sui Go
Sui Go

Reputation: 463

jQuery Modal close callback

How can I set a callback function to be ran when a modal dialog is closing, without the click of a button or close (x) icon?

Upvotes: 1

Views: 3151

Answers (2)

Muthu Kumaran
Muthu Kumaran

Reputation: 17910

you can also try,

$( ".selector" ).dialog({
   beforeClose: function(event, ui) { ... }
});

This event is triggered when a dialog attempts to close. If the beforeClose event handler (callback function) returns false, the close will be prevented.

Upvotes: 1

codeandcloud
codeandcloud

Reputation: 55200

Why dont you try the event close of jQuery UI dialog?

Code examples

Supply a callback function to handle the close event as an init option.

$( ".selector" ).dialog({
   close: function(event, ui) { ... }
});

Bind to the close event by type: dialogclose.

$( ".selector" ).bind( "dialogclose", function(event, ui) {
  ...
});

Upvotes: 1

Related Questions