KasuganoSora
KasuganoSora

Reputation: 41

How to cancel load or change page for jquery mobile?

I want cancel cancel load or change page in pagebeforecreate event for jquery mobile. what jquery mobile's function can do it?

Upvotes: 4

Views: 3336

Answers (2)

Prabhjot Singh
Prabhjot Singh

Reputation: 526

It works for me perfectly.

$.mobile.changePage( "../alerts/confirm.html", {

    transition: "pop",

    reverse: false,

});

Upvotes: 0

hgross
hgross

Reputation: 690

If possible for your specific use case, consider using the pagechangeevent instead of the pagebeforecreate. You can prevent the ajax request in the first place instead of using the ajax request's abort() method. The code would look like this:

$(document).bind("pagebeforechange", function(e, data) {
   // check data.toPage attribute here and decide if the pagechange should be canceled
   e.preventDefault();
});

Upvotes: 2

Related Questions