calling a function on jQuery model dialog close

谁说我不能喝 提交于 2019-12-24 15:24:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!