所以我有一个问题,我有一个骨干集合,用于创建函数以将数据保存到 REST API。数据被保存到服务器,模型被添加到当前集合,但是集合的添加事件没有被触发。下面是代码片段视图初始化函数
intialize : function() {
this.listenTo(this.collection, 'add', this.updateList);
},
updateList 函数只做一个控制台日志。使用集合保存数据的视图函数是:
cards = this.collection;
debugger
cards.create(data, {
success : function(model, response) {
console.log("success on saving card");
console.log(response);
console.log("Updating list");
console.log(cards);
},
error : function(model, response) {
console.log("error on saving card");
console.log(model);
console.log("response");
console.log(response);
}
})
return false;