我正在開發骨幹應用程序。我正在使用調用select
函數的主幹添加mousedown
事件。 select
函數裏面我設置了timeout
,它調用另一個函數selection
。在selection
函數中我想用console.log(this.el)
來控制currently clicked element
。但是,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);
}
@downvoter - 護理闡述? – NilsH 2013-04-23 07:22:10