Reputation: 14318
I am trying to include in this web application the library jquery-ui.
For this purpose I changed the code in this way:
require.config({
paths: {
jquery: 'libs/jquery/jquery-min',
ui: 'libs/jquery-ui/jquery-ui-min', // ******** I just added this line ********
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-optamd3-min',
text: 'libs/require/text'
}
});
require(['views/app'], function(AppView){
var app_view = new AppView;
});
Sometimes I get the following error:
jQuery is not defined
Since RequireJS loads and evaluates scripts in an undetermined order,
I suppose it depends by the fact that jquery.ui
library (which depends from jquery
), sometimes is loaded before jquery.
According the documentation I can use the order plugin
.
Anyway for backbone which requires underscore this issue never happens.
So my questions are:
Why for backbone (which depend by underscore) this issue never happens ?
I have to use the order plugin
to fix my problem for jquery-ui
?
Upvotes: 1
Views: 630
Reputation: 13105
Backbone does need the order
or some other plugin to load in order too...
Except in your case you have already made the choice to not use the normal Backbone but rather a fork from James Burke (I guess from here: https://github.com/jrburke/backbone). This is indicated by you specifying the Backbone path to backbone-optamd3-min
. Seems you have forgotten about it ;)
Using the amd branch is fine, as long as you remember you made this choice. If you decide to go with a plugin instead you could use the normal Backbone.js.
Upvotes: 2