问题
I have a small problem related to the jQuery modal dialog box. The scenario is such:
I have to call a function when i exit or close the dialog box by pressing the cross[x] button on the top right.
回答1:
Documentation
$( ".selector" ).dialog({
close: function( event, ui ) {
//write your function here or call function here
}
});
回答2:
Solution 1: Initialize the dialog with the close callback specified:
$( ".selector" ).dialog({
close: function( event, ui ) {**functionCall();**}
});
Solution 2: Bind an event listener to the dialogclose event:
$( ".selector" ).on( "dialogclose", function( event, ui ) { functionCall();} );
回答3:
You have to set the 'close' callback when you create the dialog box. Here is the documentation and an example:
http://api.jqueryui.com/dialog/#event-close
回答4:
//Image tag
<img src="" id="cross">
//jquery
$('#cross').click( function () {
// your function definition goes here
});
来源:https://stackoverflow.com/questions/17986281/calling-a-function-on-jquery-model-dialog-close