Reputation: 143
I want to dynamicaly update my 'link-to' URL, when it's model properties change. Here I've created jsbin to illustrate my problem. http://jsbin.com/
When I click "random" button - App.testModel number property changes, but URL in "Link" button doesn't update.
UPDATE
added one more property to model. http://jsbin.com/ofONeQ/25/edit
Upvotes: 1
Views: 716
Reputation: 143
Possible solution is to use - query parameters [experimental feature] - jsbin with solution
<button>{{#link-to 'test' testModel (query-params number=testModel.number)}}Link{{/link-to}}</button>
This sets up a binding between the "number" query param in the URL
NOTE: works only with ember.js 1.4.0-beta.3 and handlebars.js 1.3.0, also be sure to set:
ENV = {FEATURES: {'query-params-new': true}};
before ember is loaded
Upvotes: 0
Reputation: 47367
The link-to helper only watches the if the model sent in itself changes (not a property on the model).
That being said the model is only serialized when building the link and transitioning to the url. So even if the link doesn't update below, when you transition the url will be correct.
You also could send in the id instead of the model and it will update (because it's watching that value, and that value's changing).
http://jsbin.com/ofONeQ/23/edit
Upvotes: 1