This problem is appearing only in Internet Explorer 9, works fine with Chrome and Firefox.
Here’s my main file which loads all my dependencies :
// Filename: main.js
// Require.js allows us to configure shortcut alias
// There usage will become more apparent futher along in the tutorial.
require.config({
paths: {
jQuery: 'libs/jquery/jquery',
Underscore: 'libs/underscore/underscore',
Backbone: 'libs/backbone/backbone',
JSON: 'libs/json2/json2',
templates: '../templates'
}
});
require([
// Load our app module and pass it to our definition function
'order!app',
// Some plugins have to be loaded in order due to there non AMD compliance
// Because these scripts are not "modules" they do not pass any values to the definition function below
'order!libs/jquery/jquery-min',
'order!libs/underscore/underscore-min',
'order!libs/backbone/backbone-min',
'order!libs/json2/json2-src'
], function(App){
// The "app" dependency is passed in as "App"
// Again, the other dependencies passed in are not "AMD" therefore don't pass a parameter to this function
App.initialize();
});
And here’s where the browser crashes :
SomeRoute:function(){
facade.console.log("SomeRoute");
$("#toDelete").remove();
this.user = new User($.cookies.get('User'));
var that = this;
require(['views/SomeView'],function(SomeView){ // On this require
if(that.user.get('usr_id') > 0){
var view = new SomeView();
$("#domelement").append(that.changeView(view));
}
else window.location = APP_URL + "/login#login";
});
}
When I take this route, I get this error :
SCRIPT5022: Load timeout for modules: views/SomeView
http://requirejs.org/docs/errors.html#timeout
require.js, Line 27 Char 311
But nothing appears in Chrome or Firefox and everything works.
EDIT : Besides, refreshing the page I asked for loads it perfectly fine. It’s only when I’m taking a route. I have to refresh to access my other module content.
EDIT 2 : After some additionnal testing, I tryed to add “enforceDefine: true” to my main.js and changed my require calls. Nothing changed.
Besides, any view called with this function…
confirmView: function(idDialog, view, opts1){
facade.loader("body");
require(["text!templates/common/dialog/confirm.phtml"], function(dialogTp){
var opts = $.extend({}, facade.dialog.defaultOpts, opts1);
// Delete previous dialog with same ID
$("#"+idDialog).remove();
// select the view we'll set
var el = "#"+idDialog+" .modal-body";
// Create our template with our options
var contentDialog = _.template(dialogTp, { "option": opts, "text": "", "id": idDialog});
$("body").append(contentDialog);
require([view], function(viewClasse){
viewClasse.setElement("#"+idDialog+" .modal-body");
opts.preLoad(viewClasse);
viewClasse.render();
facade.unloader("body");
// twitter modal instance
facade.dialog.events(idDialog, opts, viewClasse);
$("#"+idDialog).modal(opts.modal);
});
});
}
… will crash aswell (timeout).
I seriously don’t know what’s going on…
Thanks for any help.
I had this problem before, and it stemmed from trying to use
orderwith normal modules, not scripts. From the old 1.0.x docs:http://requirejs.org/docs/1.0/docs/api.html#order
In any case, you should be using RequireJS 2.0 which does away with the order plugin in favour of the
shimconfiguration.