3

In a simple ember application I have a single resource ('detail') with an index template. In the application index template I have a button which calls transitionTo('detail',obj) on the index controller, where obj is the content item that was clicked. This passes obj as the model argument to my DetailRouter.setupController function, but NOT to my DetailIndexRouter.setupController function. How can I pass my context object all the way through to the 'leaf' route?

I have seen a similar question asked here, but I am working with a dynamic segment in the route.

Here is a jsfiddle.

Community
  • 1
  • 1
mike
  • 183
  • 1
  • 13

1 Answers1

7

To set the model for the DetailIndexRouter, override it's model hook and then use modelFor('detail') to access the content item from the parent route. So for example:

App.DetailIndexRoute = Ember.Route.extend({
  model: function(params) {
    return this.modelFor("detail");
  }
});

Updated fiddle here: http://jsfiddle.net/Qw8Q3/2/

Mike Grassotti
  • 19,040
  • 3
  • 59
  • 57