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
}
);
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
}
);
Share
Improve this question
edited Dec 15, 2015 at 10:19
user3335966
2,7444 gold badges32 silver badges33 bronze badges
asked Sep 7, 2012 at 18:26
Ivan JuarezIvan Juarez
1,4634 gold badges21 silver badges31 bronze badges
3
- 1 Looks like the same issue I posted over here: stackoverflow./questions/10959095/…. There's also a thread on Google Groups about it: groups.google./forum/?fromgroups#!topic/requirejs/…. We're still trying to find a resolution. – redhotvengeance Commented Sep 7, 2012 at 18:29
- 1 If you find a solution please let me know bro, will really aprettiate it!!! – Ivan Juarez Commented Sep 7, 2012 at 22:31
- We had this issue. Turned out jQuery was included twice causing random script errors on F5. jQuery was included Once in require, and another in a script tag on an MVC partial view. We removed the jQuery script tag from the view and it's working ok now; can F5 all day long. What a headache! – Noobie3001 Commented Oct 28, 2015 at 15:52
1 Answer
Reset to default 10requirejs 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.