がありbig collection
、この大きなコレクションのサブセットを別のビューに使用したいとします。
次のコードを試してみましたが、 はfiltered collection
実際には新しいものであり、 を参照していないため機能しませんBigCollection instance
。
私の質問は
、のサブセットであるコレクションを取得するにはどうすればよいBigCollection instance
ですか?
これが私のコードです。詳細については、コメントを参照してください。
// bigCollection.js
var BigCollection = Backbone.Collection.extend({
storageName: 'myCollectionStorage',
// some code
});
// firstView.js
var firstView = Marionette.CompositeView.extend({
initialize: function(){
var filtered = bigCollection.where({type: 'todo'});
this.collection = new Backbone.Collection(filtered);
// the issue is about the fact
// this.collection does not refer to bigCollection
// but it is a new one so when I save the data
// it does not save on localStorage.myCollectionStorage
}
});