Skip to content

Instantly share code, notes, and snippets.

@bcurren
Created November 25, 2010 15:43
Show Gist options
  • Save bcurren/715548 to your computer and use it in GitHub Desktop.
Save bcurren/715548 to your computer and use it in GitHub Desktop.
Todos.tasksController = SC.ArrayController.create(
SC.CollectionViewDelegate,
/** @scope Todos.tasksController.prototype */ {
summary: function() {
var len = this.get("length"), ret;
if (len && len > 0) {
ret = len === 1 ? "1 tasks" : "%@ tasks".fmt(len);
} else {
ret = "No tasks";
}
return ret;
}.property("length").cacheable(),
collectionViewDeleteContent: function(view, content, indexes) {
var records = indexes.map(function(idx) {
return this.objectAt(idx);
}, this);
records.invoke("destroy");
var selIndex = indexes.get("min") - 1;
if (selIndex < 0) selIndex = 0;
var obj = this.objectAt(selIndex);
this.selectObject(obj);
}
}) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment