在我的App.NodesIndexController
我正在做类似的事情:
destroyAllRecords: function () {
var _this=this;
Bootstrap.ModalPane.popup({
heading: 'Warning',
message: 'Are you sure you want to delete all nodes?',
primary: 'Ok',
secondary: 'Cancel',
showBackdrop: true,
callback: function(opts, event) {
if (opts.primary) {
_this.forEach(function(node) {
console.log('Deleting node %o', node);
node.deleteRecord();
});
var store = _this.get('store').commit();
store.commit();
store.on('didDelete', toggleMessageTray.bind(this, 'All nodes have been successfully deleted'));
}
}
});
}
但我实际上不知道如何收听“商店已更新”事件。我不想收听单个nodes
didDelete
事件,而是收听在执行提交后触发的全局存储事件。
三个问题:
- 有这样的活动吗?
- 商店事件在哪里定义?我没有看到关于它的文档(这是我知道的关于商店的唯一文档)
- 有没有比在循环中删除每个记录更好的方法来删除所有记录?