I would like to redirect the router to the last state the user was in.
What is the best way to do this? Is it possible to somehow use redirectTo in a router?
Here is an example. Suppose there are two main routes for a message: show and edit
App.Router = Ember.Router.extend({ post: Ember.Route.extend({ route: '/:post', show: Ember.Route.extend({ route: '/', connectOutlets: function(router, context) { router.get('applicationController').connectOutlet("showPost", post); } }), edit: Ember.Route.extend({ route: '/edit', connectOutlets: function(router, context) { router.get('applicationController').connectOutlet("editPost", post); } }) }) })
Now I would like to do something like:
post: Ember.Route.extend({ initialState: 'edit', route: '/:post', redirectTo: function(router) { router.transitionTo(router.currentState.name) }.property() })
Additional complication: RedirectTo is specific to this message, i.e. Post / 3 can edit by default, but post / 4 can show by default, depending on its last relevant states.
I suppose another way to do this is to use a parent controller / view that has its own stateManager and go to the appropriate child view. If this is the preferred method, what's wrong with using a router for this?
Any clarity here is much appreciated!
source share