Question

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?

Was it helpful?

Solution 2

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top