Reputation: 781
I'm trying to build an Android action bar-like navbar in Ember. I would like the action bar to show the route (friendly) name and have context dependant button's on the right side. I came a long way, this jsFiddle will explain things more clearly:
However, the activate event isn't I am using to figure out when a route has been changed, is only firing when one first visits the route (traversing back up the route tree won't trigger it), thus my context isn't loaded consistently.
What would be the best way to solve this problem? I know the serialize
, renderTemplate
and setupController
fire on every route change, but none of these methods are intended to be used this way. Is there perhaps a way to add a custom event to my routes, that fires on every route change?
On a side note, I am completely new to ember so I may be going about this completely the wrong way, in that case, I am eager to hear a generally better solution, than mine.
Thanks to kingpin2k's tip I was able to clean up my code a bit, for future reference here's the updated fiddle:
Upvotes: 2
Views: 92
Reputation: 47367
didTransition
/willTransition
were created for this reason. In your case didTransition
will make the most sense.
actions: {
didTransition: function(){
console.log('level two transition');
},
}
Upvotes: 2