Does the $ .mobile.loadPage function provide a callback function?

If I wanted to download content that was on a jquery mobile page that needed its own jquery script, like a slide show plugin, how do I load the html slide page and jquery slide show file in $. mobile.loadPage? Is there a callback function?

thanks

+4
source share
2 answers

You can also use "done" after loadPage. This method will be called after the page loads.

$.mobile.loadPage("page2.html", true).done(function (e, ui, page) { //page has been loaded }).fail(function () { alert("sorry, no dice"); }); 

thanks

+4
source

There is no callback function for .loadPage. However, you can bind the pageload event to run the required script.

  $( document ).bind( "pageload", function( event, data ){ //your script, and potentially testing you are on a page requiring it }); 

You can check out jQuery Mobile for full details of this event. Also, if you use the much more common .changePage method, you can use the "pageshow" or "pagebeforeshow" page event, depending on the type of script that you will use.

+1
source

All Articles