enforce js loading order
This commit is contained in:
parent
f4352cced5
commit
8d259452fa
@ -91,15 +91,21 @@ SYSTEM.prototype.load = function(id){
|
||||
system.load_css(entry['css'][i]);}
|
||||
//load js
|
||||
var call_func = true;
|
||||
var loaded = 0;
|
||||
for(var i=0; i < entry['js'].length; i++){
|
||||
system.log(system.LOG_INFO,'load js: '+entry['js'][i]);
|
||||
$.getScript(entry['js'][i]).done(function(response, status) {
|
||||
system.log(system.LOG_INFO,'load js: '+status);
|
||||
var fn = window[entry['func']];
|
||||
if(call_func && typeof fn === 'function'){
|
||||
call_func = false;
|
||||
fn();
|
||||
system.log(system.LOG_INFO,'call func: '+entry['func']);}});
|
||||
if(loaded++ == entry['js'].length-1){
|
||||
var fn = window[entry['func']];
|
||||
if(call_func && typeof fn === 'function'){
|
||||
call_func = false;
|
||||
fn();
|
||||
system.log(system.LOG_INFO,'call func: '+entry['func']);
|
||||
} else {
|
||||
system.log(system.LOG_ERROR,'call func: '+entry['func']+' - fail');
|
||||
}}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user