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