samedi 21 février 2015

find method on model hook not firing with link-to this

For CompaniesRoute I render links for each item:



{{#link-to 'company' id}}The name should change here:{{name}}{{/link-to}}


I have a (CompanyRoute) route that renders a template to edit the object. The "find" method (AJAX request) on the model hook is called.


However, if I edit the object in CompanyController (ObjectController) it does not reflect back to the item in the CompaniesRoute (CompaniesController).


What I understand on the route is that the model hook is called only when it does not already know about the model.


So when I do this instead:



{{#link-to 'company' this}}The name should change here:{{name}}{{/link-to}}


Now it works, now the name (and any other related properties) changes when I get into edit mode.


However, now the problem is that the "find" method (AJAX request) on the model hook for the CompanyRoute is not being called. It assumes that the model is already there so that it just uses the existing model with the limited properties used when calling "all" method on the CompaniesRoute model hook.


My question is how to get around this so that it's called (find method) when I use the latter ({{#link-to 'company' this}}) link-to method?


Note: also I'm using nested resources on the Router.map. ie:



this.resource('companies', function() {
this.resource('company', {path:':company_id'});
}


Note2: I'm not using Ember Data





Aucun commentaire:

Enregistrer un commentaire