Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It seems like the <code>model</code> hook for <code>App.BirdRoute</code> never gets called when navigating using <code>{{#linkTo}}</code>... maybe this is because using <code>{{#linkTo}}</code> you are passing an object to the route from the <code>birds</code> route and ember doesn't think you should need to call <code>model</code> since it thinks the id has already been deserialized into an object. This seems to make sense since <code>model</code> gets called when you reload the page.</p> <p>I used the <code>setupController</code> hook to call your <code>App.Bird.find()</code> method and pass that result into the controller. This gets called by either a direct URL or through a <code>{{#linkTo}}</code> click. If called by the <code>{{#linkTo}}</code> helper link <code>setupController</code> the <code>model</code> parameter will be the <code>bird</code> object passed with the <code>{{#linkTo}}</code> helper. If called directly from the URL the returned value from the <code>model</code> hook will be passed into <code>setupController</code> as the <code>model</code> parameter.</p> <p><a href="http://jsfiddle.net/cteegarden/TULVH/5/" rel="noreferrer">Here is a JSFiddle example</a> </p> <p><a href="http://jsfiddle.net/cteegarden/TULVH/5/show/" rel="noreferrer">example with accessible URL</a></p> <pre><code>App.BirdRoute = Ember.Route.extend({ model: function(params) { return {id: params.bird_id}; }, setupController: function(controller, model) { var bird_model = App.BirdTest.find(model.id); controller.set("content", bird_model); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload