Backbone collection groupBy无法正常工作

时间:2013-05-07 13:34:40

标签: backbone.js underscore.js

尝试了以下示例,但groupBy无法正常工作

var Todos = new Backbone.Collection();

Todos.add([
  { title: 'go to Belgium.', completed: false },
  { title: 'go to China.', completed: false },
  { title: 'go to Austria.', completed: true }
]);

// create groups of completed and incomplete models
var byCompleted = Todos.groupBy('completed');
var completed = new Backbone.Collection(byCompleted[true]);
console.log(Todos);

TypeError: Todos.groupBy is not a function
[Break On This Error]   

var byCompleted = Todos.groupBy('completed');

0 个答案:

没有答案