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

user3044258

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

user3044258

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]

編集
0

コメントを追加

0

関連記事

分類Dev

Testing Custom Hook and useEffect Not Firing

分類Dev

Model not firing parse function

分類Dev

Mousevent method not firing

分類Dev

Delegate method not firing

分類Dev

Eloquent model events not firing when using relations

分類Dev

Hook 'beforeUpdate' in a sequelize model issue

分類Dev

Is there a way to find in forms .save() method if Model Form is creating a new record or updating existing one?

分類Dev

Link the same model twice to another model in CakePhp

分類Dev

error in creating new hook method in PostgreSQL

分類Dev

Laravel Method Model Binding?

分類Dev

Model method with ManyToMany field

分類Dev

Vue: How to wait until one method completes before firing another

分類Dev

React - setTimeout() method not firing after Promise.all

分類Dev

OnApearing() method is not firing second time in Mater details page of xamarin forms

分類Dev

hook_menu_alterまたはhook_menu_link_alter?

分類Dev

Selenium - find element by link text

分類Dev

Use model method as default value for Django Model?

分類Dev

could not find method minifyEnabled()

分類Dev

How to find Scala method

分類Dev

Ember model Not Bind Dynamically using Link-to

分類Dev

How to Link MVC Model data with Angular JS Model

分類Dev

Rails 4 Sum by Model Method

分類Dev

Rails model to_s method

分類Dev

How can I hook into the return values of either Model->all() or Model->get() in Laravel 4?

分類Dev

Capybara click_link method patch

分類Dev

NoMethodError undefined method `link_to_function'

分類Dev

find if `find` method returns `nothing` in excel vba

分類Dev

Make a link to the file so that enviroment can find it

分類Dev

How to find the body and the subject in a mailto link?

Related 関連記事

ホットタグ

アーカイブ