处理对话框关闭事件 [英] Handle Dialog Close event
问题描述
我的帖子提交了表单,并在成功提交所有内容后显示对话框.我很好奇,当该对话框由右上角的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屋!