3

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?

stephanos
  • 3,319
  • 7
  • 33
  • 47

1 Answers1

1

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?

Community
  • 1
  • 1
Shane Davis
  • 952
  • 1
  • 6
  • 22
  • I use require.js already :) The issue of the question is not how to just split the files - but how do LOAD them in the end. – stephanos Jan 03 '13 at 18:13