Suppose I enter the ‘user’ state in the following Ember code:
Html:
<button {{action doSomething App.currentUsername}}>Go!</button>
JS:
App.Router = Ember.Router.extend({
enableLogging: true,
root: Ember.Route.extend({
doSomething: Ember.Route.transitionTo('user'),
main: Ember.Route.extend({
route: '/'
}),
user: Ember.Route.extend({
route: '/:username',
connectOutlets: function(router, context) {
//some actions
}
})
})
});
When ‘doSomething’ action is called again I want Ember to rerun the connectOutlets code (because the username would have changed).
Putting the code in a ‘doSomething’ action inside ‘user’ doesn’t work beacause I need the context.
Any idea how to do that?
Thanks
Apparently in Ember, if a state is called with the same context object it will not connect the outlets (or not even enter the state in the first place). The way to fix this is simply by providing a new context, so we replace ‘doSomething’ with: