jquery - jqm+backbone.Js+require.Js show loading message before page load -


i' m using jquery mobile 1.1, want show loading message before page load using backbone router. mobile init code is

$(document).bind("mobileinit", function() { $.mobile.ajaxenabled = false; $.mobile.linkbindingenabled = false; $.mobile.hashlisteningenabled = false; $.mobile.pushstateenabled = false;  $.mobile.showpageloadingmsg="loading";} 

but loading message not shown. suggestions?

usual way not going because jquery mobile show loader if page loading dom more 10ms, hide when page loaded dom. if page complex long before page show.

but can manually show/hide it.

here's working example: http://jsfiddle.net/gajotres/qx7yn/

$(document).on('pagebeforecreate', '[data-role="page"]', function(){          var interval = setinterval(function(){         $.mobile.loading('show');         clearinterval(interval);     },1);     });  $(document).on('pageshow', '[data-role="page"]', function(){       var interval = setinterval(function(){         //$.mobile.loading('hide');         clearinterval(interval);     },1);       }); 

basically want show loader when page created , hide during pageshow event. in case line :

//$.mobile.loading('hide'); 

is commented because page simple , load in moment. dont forget use this:

$.mobile.loader.prototype.options.text = "loading"; $.mobile.loader.prototype.options.textvisible = true; $.mobile.loader.prototype.options.theme = "a"; 

everything need in jsfiddle example.

edit :

this example compatible jquery mobile 1.1.: http://jsfiddle.net/gajotres/qx7yn/


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -