pagebeforeload eventversion added: 1.0
Description: Triggered before any load request is made.
jQuery( ".selector" ).on( "pagebeforeload", function( event ) { ... } )
Callbacks bound to this event can call preventDefault()
on the event to indicate that they are handling the load request. Callbacks that do this *MUST* make sure they call resolve()
or reject()
on the deferred object reference contained in the data object passed to the callback.
The data object, passed as the 2nd arg to the callback function contains the following properties:
-
url
(string)- The absolute or relative URL that was passed into
$.mobile.loadPage()
by the caller.
- The absolute or relative URL that was passed into
-
absUrl
(string)- The absolute version of the url. If url was relative, it is resolved against the url used to load the current active page.
-
dataUrl
(string)- The filtered version of absUrl to be used when identifying the page and updating the browser location when the page is made active.
-
deferred
(object)- Callbacks that call
preventDefault()
on the event, *MUST* callresolve()
orreject()
on this object so thatchangePage()
requests resume processing. Deferred object observers expect the deferred object to be resolved like this:123456789101112131415$( document ).on( "pagebeforeload", function( event, data ) {
// Let the framework know we're going to handle the load.
event.preventDefault();
// ... load the document then insert it into the DOM ...
// at some point, either in this callback, or through
// some other async means, call resolve, passing in
// the following args, plus a jQuery collection object
// containing the DOM element for the page.
data.deferred.resolve( data.absUrl, data.options, page );
});
or rejected like this:
1234567891011121314$( document ).on( "pagebeforeload", function( event, data ) {
// Let the framework know we're going to handle the load.
event.preventDefault();
// ... load the document then insert it into the DOM ...
// at some point, if the load fails, either in this
// callback, or through some other async means, call
// reject like this:
data.deferred.reject( data.absUrl, data.options );
});
- Callbacks that call
-
options
(object)- This object contains the options that were passed into $.mobile.loadPage().