Skip to content

Instantly share code, notes, and snippets.

@juanghurtado
Created February 22, 2013 12:40
Show Gist options
  • Save juanghurtado/5013152 to your computer and use it in GitHub Desktop.
Save juanghurtado/5013152 to your computer and use it in GitHub Desktop.
define(['backbone','modules/todo/models/todo', 'backbone.localstorage'],function(Backbone, Todo) {
var isCompleted = function(todo) {
return todo.get('done');
};
var Collection = Backbone.Collection.extend({
model: Todo,
localStorage: new Backbone.LocalStorage('todosmvc:todos'),
comparator: function(todo) {
return todo.get('date');
},
getCompleted: function() {
return this.filter(isCompleted);
},
getNotCompleted: function() {
return this.reject(isCompleted);
}
});
return Collection;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment