Skip to content

Instantly share code, notes, and snippets.

@petermichaux
Created May 6, 2012 04:39
Show Gist options
  • Save petermichaux/2613483 to your computer and use it in GitHub Desktop.
Save petermichaux/2613483 to your computer and use it in GitHub Desktop.
TodosModel
maria.SetModel.subclass(checkit, 'TodosModel', {
methods: {
getDone: function() {
return this.filter(function(todo) {
return todo.isDone();
});
},
getUndone: function() {
return this.filter(function(todo) {
return !todo.isDone();
});
},
markAllDone: function() {
this.forEach(function(todo) {
todo.setDone(true);
});
},
markAllUndone: function() {
this.forEach(function(todo) {
todo.setDone(false);
});
},
deleteDone: function() {
this['delete'].apply(this, this.getDone());
}
}
});
// ----
//
// var todos = new checkit.TodosModel(); // create a todos set
// todos.add(new checkit.TodoModel()); // add a todo to the set
@petermichaux
Copy link
Author

That was a mistake in the commented code at the bottom. Fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment