javascript - $(window).on("load") not triggered in postRender -


i have jquery code have trigger after page loaded, doing in postrender function call of view, postrender , window load event totally async, so, window load event might happen before in postrender adding listener load event, there replacement function in case, or missing something?

thanks help

you use flag keep track of window.load event in global scope , choose execution path in postrender() based on status of flag.

// define in global scope var windowhasloaded = false; $(window).on('load', function(){     windowhasloaded = true; }); 

then in view.postrender():

// window has loaded, run if(windowhasloaded) {     dostuff(); } // run on window load event else {     $(window).on('load', dostuff); }  var dostuff = function() {     // stuff } 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -