我有一个集合数组(coll_array)。所有集合都绑定到所有事件的相同函数 (process_coll)。这意味着,对数组中任何集合的任何更改都会导致执行相同的函数。我的问题是如何识别发生事件的集合。如果我可以将参数传递给目标函数,我可以传递集合的标识,但据我所知,在 Backbone 事件中没有办法做到这一点。
initialize: function(){
_(this).bindAll('process_coll');
coll_array ; //array of collections
for(var i=0;i<coll_array.length;i++)
coll_array[i].bind('all', this.process_coll);
coll_array[i].fetch();
}
process_coll: function(){
//some code here
//how do I get the specific collection which resulted in execution of this function?
}