Ember.js RC1 "model" hook on a route that is not called

It seems that the model hook does not work as described for RC1. The model hook is not called when linkTo used instead of directly visiting the element, editing the URL in the browser.

Given this example application: http://jsfiddle.net/wmarbut/QqDjY/

When visiting directly in '/ # / edit-item / 3', the hook model is called, however, when the linkTo call linkTo used to direct the user to the same page, the model hook is not called.

Given the documentation here http://emberjs.com/guides/routing/specifying-a-routes-model/ , I cannot find anything to explain this. Is this a mistake or am I doing it wrong?

Edit I do not use Ember Data and do not plan.

+4
source share
1 answer

It seems that the model hook does not work as described for RC1. The model hook is not called when linkTo is used instead of directly visiting the element by editing the URL in the browser.

This is the exact way to work. This is due to the fact that the model is provided through linkTo . When you write {{linkTo posts post}} , the model is the third argument. There is no need to call a model hook. The model hook is only executed when entering state through the URL, because it must search for the model.

In your fiddle, you have {{#linkTo editItem item.id}}{{item.name}}{{/linkTo}} . You do not need to do this. You must have {{#linkTo editItem item}}{{item.name}}{{/linkTo}} . However, this will not solve the problem. This will do an automatic search.

+6
source

All Articles