[英]Backbone update collection with json
我有模型的骨干收藏。
我使用文件上传插件:
$('#file-areas-fileupload').fileupload({
....
dataType: 'json',
done: function (e, data) {
self.collection.parse(data.result);
}
});
我想在响应到来时更新集合中的现有模型。 但:
self.collection.parse(data.result);
self.collection.add(data.result);
不管用。 是否有一种解决方案来更新集合或唯一的方法是fetch
集合...?
通过在浏览器或console.log()或警报中进行调试来检查“ e”和“数据”的值。 我认为您的代码可能如下所示
self.collection.parse(e.result);
self.collection.add(e.result);
self.collection.set(response.result)
帮助了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.