Reputation: 67
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
Upvotes: 0
Views: 229
Reputation: 31732
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 */
}
});
Upvotes: 1