Search code examples
ember.jshandlebars.jsember-routerember-model

Ember deeply nested routes do not keep parent dynamic parameter


I've got this ember application:

Ember       : 1.3.2
Ember Model : 0.0.11
Handlebars  : 1.3.0
jQuery      : 1.9.1 

Using this resource map:

App.Router.map(function () {
  this.resource('dimensions', function() {
    this.resource('dimension', { path: ':dimension_id'}, function () {
      this.resource('value', { path: 'values/:value_id' });
    });
  });
});

And this allows me to embed {{outlet}} in "dimensions" template that fills with "dimension" template, and embed {{outlet}} in "dimension" template that fills with "value" template as well.

All works very well except for the link-to helper in the "value" template, that does not accept more params nor accepts other models as described in ember API documentation.

Which is the best way of dealing with link-to in deeply nested routes?

I've got this fiddle to show my problem: http://jsfiddle.net/vsiguero/pQpE3/5/

Thanks for your help!


Solution

  • EDIT: The paramsFor method was added some time after I wrote this answer, which makes this possible. Refer to @nickiaconis' answer for more details.


    If I understand you correctly, I think you're running into expected behavior. The parameters for a route are unique to that route. I'm not 100% sure why that is, but dynamic segment values don't get passed to child routes. What you should do instead is access the model directly. In your value route, you can use this.modelFor('dimension') to get the model that was resolved for the dimension route.