mercredi 20 janvier 2016

Ember push record in model and update template

I have this model in my Ember app:

model: function(params, transition) {
    var self = this;

    return Ember.RSVP.hash({
        photo: self.store.find('photo', params.id),
        comments: self.store.query('comment', {id: params.id})
    });
},

and an action that creates a new comment record:

actions: {
    newComment: function(comment) {
        var record = this.store.createRecord('comment', comment);

    }
}

Now I need to add the new comment to the current model's comments (without persisting the new comment on the server) and refresh the template that uses a {{#each}} loop to show the comments; I've tried many things but nothing works; is this possible?




Aucun commentaire:

Enregistrer un commentaire