Browse Source

change async loading into one-by-one loading

pull/67/head
tangkikodo 10 years ago
parent
commit
b8c64ac165
  1. 26
      src/canvas/view/CanvasView.js

26
src/canvas/view/CanvasView.js

@ -39,19 +39,21 @@ function(Backbone, FrameView) {
var that = this;
frame.el.onload = function () {
var scripts = that.config.scripts,
var scripts = that.config.scripts.slice(0), // clone
counter = 0;
scripts.map(function (scriptUrl) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = scriptUrl;
script.onerror = script.onload = function () {
counter++;
if (counter == scripts.length) that.renderBody();
};
frame.el.contentDocument.head.appendChild(script);
});
function appendScript(scripts) {
if (scripts.length > 0) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = scripts.shift();
script.onerror = script.onload = appendScript.bind(null, scripts);
frame.el.contentDocument.head.appendChild(script);
} else {
that.renderBody();
}
}
appendScript(scripts);
};
},

Loading…
Cancel
Save