문제

I am using EAK with a simple nested routing structure, but changing the parent model in the child controller does not change the top-level view. For example if I have the following router.js file:

this.resource('similar', function() {
    this.resource('list', { path: '/list/:phone_id' });
    this.resource('upload');
    this.resource('new');
});

For the 'similar' route model I am using ember-data together with the RESTAdapter which is backed Flask.

export default Ember.Route.extend({
    model: function() {
        return this.store.find('phone');
    }
});

If I manipulate the model inside the 'upload' controller then the changes are not reflected in the template, e.g.

var record = this.store.createRecord('phone', {
    numbers: [1,2,3,4]
});

record.save();

will not change "{{#each list in model}} {{list.numbers}} {{/each}}". If I reload the page it works fine. What am I doing wrong?

도움이 되었습니까?

해결책 2

The problem here was that the REST endpoint did not return the new record (with the id attribute set).

다른 팁

Instead of store.find which hits the server and stores that exact list, try using store.filter. store.filter "remains up to date as new records are loaded into the store or created locally"

http://emberjs.com/api/data/classes/DS.Store.html#method_filter

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top