Reputation: 19802
I have a Backbone view as a requirejs module. The problem is that requirejs load the http://localhost/remote/script/here.js before the view is even initialized. Is it because the script isn't inside a requirejs module?
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;
});
Upvotes: 0
Views: 450
Reputation: 4238
you try to define the view Backbone after the load the module. You can do this, in the define () method of RequireJS. The array of this function contains parameters that defines module dependencies.
Upvotes: 0
Reputation: 13105
The array you have as the first argument to define
is the depedencies of your view. So yes it is loaded and parsed before the View
.
Also note that unless you use modified versions of backbone and underscore, they ar not AMD compliant. You will need to wrap them with a plugin to load them properly.
Upvotes: 1