我有一个Backbone视图作为requirejs模块。问题是requirejs在视图被初始化之前加载http://localhost/remote/script/here.js。是否因为脚本不在requirejs模块中?RequireJS在视图初始化之前加载脚本
define([
'jquery',
'undescore',
'backbone',
'http://localhost/remote/script/here'
], function($, _, Backbone, Luajs){
var View = Backbone.View.extend({
initialize : function(options) {
},
render : function() {
this.$el.html('<p>my view</p>')
return this;
}
});
return View;
});
我使用主干和下划线的修改版本。为了加载异步我的脚本,我必须将它们包装在一个define()中? – chchrist 2012-04-25 15:39:34
define需求参数中的模块异步加载。当它们被加载时,定义中的函数被调用。 – ggozad 2012-04-25 16:26:33
嗯,所以我无法控制何时加载它们? – chchrist 2012-04-25 16:31:59