私はバックボーンのソースであるイベント部分を調べていますが、コンテキストが2回格納されている行を除いて、ほとんどの場合それは理にかなっています。
あるケースでは、に渡された値を取得しますon()。2番目のインスタンスでは、渡された値を取得しますが、渡されなかった場合は、現在のコンテキストを取得します- this。
on: function(name, callback, context) {
if (!(eventsApi(this, 'on', name, [callback, context]) && callback)) return this;
this._events || (this._events = {});
var list = this._events[name] || (this._events[name] = []);
list.push({callback: callback, context: context, ctx: context || this}); // here
return this;
},
紛らわしいのは、this._events[name]ローカル変数に保存される場合list(オンとオフ)と、ローカル変数に保存される場合effects(トリガー)です。
それぞれの明示的な使用
.ctxで使用されtriggerEvents()ます。.contextで使用されoff()ます。