jquery/jquery-mobile — pull request #4884 by tqc (2012-08-22 07:10:49+00:00)
Title: Navigation: enable adding custom code to loadPage

Add a new option $.mobile.loadPage.defaults.completeLoad which allows the user to define when a page has been fully loaded.

By default the existing functionality is unchanged - a page is considered loaded when the html has been added to the dom.

If pages include large images which are not preloaded or other asynchronous components, the page may be displayed before it is fully rendered.

Adding the below code (and the waitForImages plugin) to the app keeps the loading message visible for longer and does not start the transition until the page is actually ready to be displayed.

$.mobile.loadPage.defaults.completeLoad = function(page, callback ) {
$(page).waitForImages(function() {
callback();
});
};