Skip to content Skip to sidebar Skip to footer

How To Bind To Jquery-mobile Pagebeforeload Event?

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.

Solution 1:

Your code worked for me exactly as it is.

enter image description here

Be sure to note that this will only work if you are loading a separate page. It will not work for internally linked pages because it is not actually loading a page.

Solution 2:

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 );

});

Post a Comment for "How To Bind To Jquery-mobile Pagebeforeload Event?"