mardi 30 décembre 2014

ember.js - swap out a nested resource from any route

I have routes with nested dynamic segments, for example /:locale/products/:product_id/items/:item_id etc nesting. I want to swap out the locale in an action in the locale route. I don't want to transition to the base /:locale route when I change the locale.


locale route action:



actions: {
localeChanged: function(locale) {
var route = this.controllerFor('application').get('currentRouteName');
this.transitionTo(route, locale);
}
}


This only works when I'm not deeply nested. I would like to avoid implementing the localeChanged action in every route to provide the exact models needed for a given route.





Aucun commentaire:

Enregistrer un commentaire