处理对话框关闭事件 [英] Handle Dialog Close event

查看:130
本文介绍了处理对话框关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的帖子提交了表单,并在成功提交所有内容后显示对话框.我很好奇,当该对话框由右上角的X关闭以关闭其他对话框(例如另一个对话框)时,如何更改事件.

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');
}); 

我想做

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

成功的购买"对话框关闭时

when the successfulPurchase dialog is closed out

推荐答案

如果要在关闭对话框时重定向用户,请使用pagecontainerbeforechange事件用新的目标页面更改toPage.要确定导航方向是否为 back ,请检查options.direction的值. prevPage是上一页/对话框的jQuery对象.

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 */
    }
});

这篇关于处理对话框关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆