Reputation: 9675
I have complete contact edit dialog. I now would like to create the matching new contact dialog with the least necessary effort. The new dialog is identical, appart from the model initialisation.
I have the following New route:
App.ContactNewRoute = App.BaseEntityRoute.extend({
init: function () {
this._super();
this.keyName = "contact_id";
this.controllerRoute = "contact.new";
this.datasource = App.contactDataSource.getNewContact;
}
});
How can I tell ember that it should use the ContactEditController and ContactEditView for this route?
Upvotes: 2
Views: 1028
Reputation: 111
Ember mixin can also be used for this: http://emberjs.com/api/classes/Ember.Mixin.html
Upvotes: 1
Reputation: 11668
If you want to reuse the class, why not try something like this?
App.ContactNewController = App.ContactEditController.extend();
App.ContactNewView = App.ContactEditView.extend();
Ember now finds the classes based on its naming schema and everything should be fine. But why do you actually need that? You are basically mirroring all parts of an route in a new route with a new name, but all other components (controller, view) stay the same?
Upvotes: 3