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
After playing around found I have to add setupController on the CompanyRoute:
setupController: function(controller, model) {
controller.set('model', App.CompanyAdapter.find(model.id));
this._super(controller, model);
}
This will now fire request each time and reflect changes accordingly based on link-to helper with this attribute.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加