addyosmani / addyosmani/backbone-fundamentals
Collections {merge: true} unclear
- 主要言語
- Rich Text Format
- スター
- 9.2k
- フォーク
- 1.4k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
> Also note that when using add() on a collection, passing {merge: true} causes duplicate models to have their attributes merged in to the existing models, instead of being ignored.
```
var items = new Backbone.Collection;
items.add([{ id : 1, name: "Dog" , age: 3}, { id : 2, name: "cat" , age: 2}]);
items.add([{ id : 1, name: "Bear" }], {merge: true });
items.add([{ id : 2, name: "lion" }]); // merge: false
console.log(JSON.stringify(items.toJSON()));
// [{"id":1,"name":"Bear","age":3},{"id":2,"name":"cat","age":2}]
```
What exactly is a "duplicate model"? It seems to be where they have the same id, but I'm not sure.
And does `items.add([{ id : 2, name: "lion" }]); // merge: false` log out some sort of error?
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。