how can add native javascript $.when
? error doing below when want use each inside $.when
. ideas?
var scripts = [ "ccommon.js", "ccommon2.js", "ccommon3.js" ]; $.when( // via $.getscript. for(var = 0; < scripts.length; i++) { $.getscript(scripts[i]); } ).done(function(){ //place code here, scripts loaded. alert('script loaded'); });
you need pass list of promise objects as argument list $.when(p1, p2, p3).then(function())
since in case have dynamic list, can use .apply() function invoke $.when() dynamic list of parameters
var array = []; for(var = 0; < scripts.length; i++) { array.push($.getscript(scripts[i])); } $.when.apply($, array).done(function(){ //place code here, scripts loaded. alert('script loaded'); });
Comments
Post a Comment