Sample Code:
this.books = this.getBooksFromDatabase();
this.publishedBooks = this.books.filter(function(book) {
return book.get(\"isPublished\") === \"1\";
You could either instantiate a new backbone collection and pass in the array.
var myPublishedBooks = new MyBooksCollection(publishedBooks);
Or you could refresh your original collection.
this.books.refresh(publishedBooks)
Note that the 0.5.0 release in July 2011 renamed refresh
to reset
, so you can achieve this in newer versions of Backbone with;
this.books.reset(publishedBooks)