Is there any way to automatically extend routes and controller ? I want them to extend from GenericRoute and GenericController (which I have overload) and I want the routes and controllers which would be generated by Ember, to be extended from my Generic"Stuff"…
As I have the list of the route/controller names, my first attempt was to do the stuff in the App.initializer:
App.initializer({
...
initialize: function(container, application) {
for (var name in names) {
var routeName = name+'DisplayRoute';
App[routeName] = App.GenericDisplayRoute.extend();
}
}
});
In this example, it would generate <name>DisplayRoute routes, but I got an Uncaught #<error> when I reload my browser…
I’m not entirely sure this is the correct “Ember way”, but what about just reopen() the Ember.Route and Ember.Controller? Then anything created from them will get your modifications. Checkout the object Guide for a quick overview.
If you’re using globals, you can define App.Controller and App.Route and ember will use those instead of Ember.Controller and Ember.Route. You’ll also need to implement App.ArrayController and App.ObjectController if you want to use them.