只是有點瑣事; 我在一個循環中創建視圖和模型,然後試圖綁定自定義事件給他們。到目前爲止,所有的咕咕,但當我想找出與對象解僱的事件呢。我知道有其他更囉嗦的方式串聯單獨分配活動,每個人,但我想我正在尋找一種更有效的方式:骨幹自定義事件:讓呼叫者對象
initialize: function(args)
{
this.views = [];
this.models = [];
for(var i =0;i<args.items.length;i++)
{
this.models[i] = new BasicContentModel({url:args.items[i].urlRoot+args.items[i].url});
this.views[i] = new BasicContentView({model:this.models[i],id:i,className:"tab-"+i});
this.views[i].bind("updated",this.update,this) //<-- heres the bind
}
// blah blah
},
update: function(args)
{
console.log("updating:",args) //<-- trying to get which one called the update
}
這是否有道理?基本上我要記錄哪些視圖剛剛更新(向上冒泡排序的事情)