mardi 6 octobre 2015

How to update model data when store is updated emberjs

I have a route defined as follows:

Ember.Route.extend({
    model : function(params) {
         return Ember.RSVP.hash({
             posts : store.find('post', {date : params.date, page : params.page})
         });
    },
    setupController : function(controller, model) {
        this.set('model', model.posts);
    }
});

Everything works fine and the data gets loaded. Now I've decided to load data dynamically from controller. So in the corresponding controller, I did as below:

Ember.ArrayController.extend({
    Ember.RSVP.hash({
             posts : store.find('post', {date : params.date, page : params.page})
    }).then(function(data) {
        this.store.pushPayLoad(this.store.modelFor('post'), data); 
    }.bind(this));
});

In the above way, I was able to get the data loaded in Ember Store but it is not loaded into the model. What is the recommended way so that the model gets updated as soon as the data is available in the store.

Aucun commentaire:

Enregistrer un commentaire