mardi 25 août 2015

Ember 2.0.0 Reset state on model

I recently upgraded from a pretty old Ember version to 2.0.0 and I'm having lots of trouble figuring out how to upgrade this part of my code.

I have some embedded relationship, whenever I save my models, I have to manually reset the state of my child otherwise they will stay in an unwanted state.

I used to do it this way :

this.get('content').save().then(function(page) {
    page.get('page_translations').forEach( function(record) {
        record.send('willCommit');
        record.set('_attributes', {});
        record.send('didCommit');
    });

    scope.transitionToRoute('pages.pages');
}).catch(function(reason) {
    console.log(reason);
}

Unfortunately this doesn't seem to work no more and after countless trial and errors, I'm getting kind of desperate.




Aucun commentaire:

Enregistrer un commentaire