lundi 28 septembre 2015

How do I initialize a child index route with a dynamic segment in Ember?

I'm trying to piece together an index route that initializes to the first item of a returned collection from the parent route. In this case we gather 'plans' for a specific user and would like to serialize the index route to their first plan id. So 'app/USER_ID' would route to 'app/USER_ID/FIRST_PLAN_ID'. In addition the index route that utilizes the plan id would have child routes that we want to hit directly via url.

  this.route('dashboard', {path: '/:client_id'}, function() {
       this.route('index', {path: '/:plan_id'}, function() {

This index route will have child routes. The problem with this approach is that the 'dashboard' route's hooks do not get hit once I add in the index route, and it's not included in the transition object that's passed to the children (it's as if it's replaced by the index route).

We first went the route of doing a manual transition from the dashboard route to a child route called 'home' instead of index. This initialized properly but the transition caused any nested route under 'home' to be inaccessible via URL due to the 'transitionTo' at the dashboard level. For example, attempting to navigate to 'app/USER_ID/PLAN_ID/ACCOUNT_ID' would resolve to 'app/USER_ID/PLAN_ID' because a hook in the parent route would essentially scrub the rest of the route. How would one properly initialize a route to a dynamic segment using a dynamic segment in the parent route without losing the ability to navigate to descendant routes?




Aucun commentaire:

Enregistrer un commentaire