私はバックボーンアプリに取り組んでいます。mousedown
関数を呼び出すバックボーンを使用してイベントを追加していselect
ます。関数内では、別の関数を呼び出すselect
設定をしています。関数では、を使用してコンソールしたい。ただし、this は現在のモジュールを参照していないため、未定義です。選択関数で使用できるように、このキーワードを保持するにはどうすればよいですか?timeout
selection
selection
currently clicked element
console.log(this.el)
this.el
これが私のコードです
events: {
'mousedown': 'select',
'mouseup': 'deselect'
},
select: function () {
this.timeoutId = setTimeout(this.selection, 1000);
},
deselect: function () {
clearTimeout(this.timeoutId);
},
selection: function () {
console.log(this.el);
}