I have a four step wizard process for creating a record. I am trying to figure out how to reuse the same templates and controllers for editing records. Ideally, I would prefer to have different routes for creating and editing, but I would be open to using the same routes as well. I have identified two ways that I might be able to do this.
One way would be to be to define new routes for editing the record and tell the routes to use the existing controllers and templates. Something like this:
Dfw.ActivityEditNameRoute = Em.Route.extend
model: ->
@modelFor('activity')
renderTemplate: (controller, model)->
existingController = @controllerFor('new_activity.name')
existingController.set('model', model)
@render 'new_activity/name',
controller: existingController
outlet: main
The other way would be to try to componentize the wizard.
Is one of these two approaches preferred or is there another approach that I have not thought of?
EDIT: I did a bit more research and I see that someone asked a similar question about a year and a half ago (ancient history in the ember world). Sharing a controller / template for different routes The suggested solution was to do the renderTemplate
and setupController
technique in the route. Does this still hold true or are there newer techniques?