簡體   English   中英

JSON的骨干更新集合

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM