4

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

Charles Sprayberry
  • 7,741
  • 3
  • 41
  • 50
KasuganoSora
  • 41
  • 1
  • 3

2 Answers2

2

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();
});
hgross
  • 690
  • 6
  • 15
0

It works for me perfectly.

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

    transition: "pop",

    reverse: false,

});
Community
  • 1
  • 1
Prabhjot Singh
  • 526
  • 1
  • 3
  • 17