4
votes

It appears the model hook is not working as documented for RC1. The model hook is not being called when a linkTo is used instead of visiting the item directly by editing the url in the browser.

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

When visited directly at '/#/edit-item/3', the model hook is called, however when a linkTo call is 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 can't find anything to explain this. Is this a bug or am I doing it wrong?

Edit I'm not using Ember Data nor do I plan to.

1

1 Answers

6
votes

It appears the model hook is not working as documented for RC1. The model hook is not being called when a linkTo is used instead of visiting the item directly by editing the url in the browser.

This is the exact way it's supposed to work. This is because the model is given via linkTo. When you write {{linkTo posts post}} the model is the 3rd argument. There is no need to call the model hook. The model hook is only executed when entering a state via the URL because it must look up a model.

In your fiddle you have {{#linkTo editItem item.id}}{{item.name}}{{/linkTo}}. You do no need to do that. You should have {{#linkTo editItem item}}{{item.name}}{{/linkTo}}. This will not solve the "problem" however. It will make the lookup automatic.