Reputation: 3339
I want to load parts of my Ember.js application on demand (app is structured with AMD but merged into a few big script files for production).
An example:
Browse to '/'
The user starts at /
, the HTML loads the file core.js
which contains Ember.js, the routings and the application controller + view.
Browse to '/user/settings'
So now the user browses to /user/settings
for the first time. The views, controllers and templates for this are in user.js
which is loaded via a script loader in the according route:
App.UserRoute = Em.Route.extend({
enter: function(ctx) {
this.ajaxLoadFiles("user.js", function() {
// ???
});
}
});
Problem
Somehow Ember.js needs to wait for the script to load and then continue routing ... how do I do this?
Upvotes: 3
Views: 1178
Reputation: 952
I am using require.js, it is great for modularising your code!
You can clone the todoMVC AMD version to study here
https://github.com/addyosmani/todomvc/tree/gh-pages/dependency-examples/emberjs_require
for further advice, see this post:
Is there any way to split an Ember.js app across a few files?
Upvotes: 1