addyosmani / addyosmani/backbone-fundamentals

Code doesn't work

未关闭
#692 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rich Text Format
星标
9.2k
派生
1.4k
PR 合并指标
30 天内没有已合并 PR

描述

In https://github.com/addyosmani/backbone-fundamentals/blob/gh-pages/chapters/03-internals.md

The code below out put the following error `Uncaught TypeError: TodosCollection.set is not a function(…)`

```
var TodosCollection = new Backbone.Collection();

TodosCollection.add([
{ id: 1, title: 'go to Jamaica.', completed: false },
{ id: 2, title: 'go to China.', completed: false },
{ id: 3, title: 'go to Disneyland.', completed: true }
]);

// we can listen for add/change/remove events
TodosCollection.on("add", function(model) {
console.log("Added " + model.get('title'));
});

TodosCollection.on("remove", function(model) {
console.log("Removed " + model.get('title'));
});

TodosCollection.on("change:completed", function(model) {
console.log("Completed " + model.get('title'));
});

TodosCollection.set([
{ id: 1, title: 'go to Jamaica.', completed: true },
{ id: 2, title: 'go to China.', completed: false },
{ id: 4, title: 'go to Disney World.', completed: false }
]);
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。