Handle Dialog Close event

喜你入骨 提交于 2019-12-12 04:34:25

问题


My post submits the form and displays the dialog after it successfully submits everything. I am curious as how to change the event when this dialog is closed out by the X in the top corner to close something else as well such as another dialog.

$.post("test.php", $("#payment-form").serialize(),function(){ 
   $.mobile.changePage('#successfulPurchase');
}); 

I want to do

$("#subscribePage").dialog('close');

when the successfulPurchase dialog is closed out


回答1:


If you want to redirect a user when a dialog is close, use pagecontainerbeforechange event to alter toPage with a new target page. To determine whether the navigation direction is back, check value of options.direction. prevPage is a jQuery object of previous page/dialog.

$(document).on("pagecontainerbeforechange", function (e, data) {
    if ( typeof data.toPage == "string" && data.options.direction == "back" && data.prevPage.hasClass("ui-dialog") ) {
        data.toPage = "#homepage"; /* redirect to homepage */
    }
});


来源:https://stackoverflow.com/questions/26996375/handle-dialog-close-event

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