I'm getting desperate trying to get the jQuery mobile pagebeforeload event to fire. This just does nothing:
$(document).on("pagebeforeload", function( e, data ) {
console.log("hello");
});
According to the JQM docs, the syntax is correct. Still, nothing happens. Can anybody tell me why that is?
Make sure you're including preventDefault();
Otherwise, it'll just merrily continue loading.
Docs: http://jquerymobile.com/demos/1.1.0/docs/api/events.html
$( document ).bind( "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 );
});