示例代碼:過濾骨幹集合返回模型的數組
this.books = this.getBooksFromDatabase();
this.publishedBooks = this.books.filter(function(book) {
return book.get("isPublished") === "1";
});
這裏躺着的問題:
this.books.filter,返回模型的數組。我已經試過包裝的陣列,因爲這樣的:
var publishedBooks = _(this.books.filter(function(book) {
return book.get("isPublished") === "1";
}))
所推薦的這篇文章: https://github.com/documentcloud/backbone/issues/120
,但我仍然不能運行的東西,如: publishedBooks.each(...)或 publishedBooks.get(...)
我在想什麼?有沒有辦法將返回的數組轉換爲集合?
Collection#refresh已重命名爲Collection#reset http://documentcloud.github.com/backbone/#Collection-reset –