Here is my controller action:
saveArticle(article, blocks) {
let self = this;
return RSVP.all(article.get('blocks').invoke('destroyRecord')).then(function () {
blocks.data.map(function (item) {
let block = self.get('store').createRecord('block', {
article: article,
type: item.type,
format: item.data.format,
text: item.data.text,
});
block.save();
article.get('blocks').pushObject(block);
debug('Block added.');
});
//article.save();
});
}
How can I perform article.save () right after all the blocks have been created? That is, I want to delete all current blocks, create new ones, and save the article only after all these actions have been executed. I appreciate any ideas!
Aucun commentaire:
Enregistrer un commentaire