Reputation: 1463
When I press F5 to reload my app sometimes throws errors and sometimes it does not.
I am debugging with Chrome. Sometimes the console reports this error:
Uncaught ReferenceError: unit_directionals is not defined
sometimes throws that a reference is not defined like in this case for jquery: "Uncaught ReferenceError: jQuery is not define"
What can be wrong if i have defined the files in the correct way?
this is the code I have in the main.js pointed in the main index html:
requirejs.config({
baseUrl: 'js/lib',
paths:{
app:'../app',
models: '../app/models',
views: '../app/views'
}
})
requirejs(
[
//load lib in this order
'underscore', 'handlebars', 'jquery','backbone', 'uri',
//load models, views...
'app/models/items.model', 'app/models/results.model',
'app/views/items.view', 'app/views/results.view',
'app/index'
],
function(jQuery,$,_....) {
//init app
}
);
Upvotes: 5
Views: 3186
Reputation: 6766
requirejs loads modules async and they can load out of order -- they are not guaranteed to load in the order specified in the require call. If the script is an AMD module, and calls define() with its dependencies, this is not a problem.
However, if the script just uses browser globals and implicit dependencies, like backbone and probably handlebars, then the shim config is needed to properly express the dependencies and export value.
Upvotes: 10