初期化中に、ビューからコレクション内の各モデルに値を渡す必要があります。
コレクションまで、Backbone.Collectionコンストラクターの「options」で渡すことができます。
この後、コレクション内の各モデルにいくつかの「オプション」を渡すことができるテクニックはありますか?
var Song = Backbone.Model.extend({
defaults: {
name: "Not specified",
artist: "Not specified"
},
initialize: function (attributes, options) {
//Need the some_imp_value accessible here
},
});
var Album = Backbone.Collection.extend({
model: Song
initialize: function (models, options) {
this.some_imp_value = option.some_imp_value;
}
});