我有一个组件会触发onFocus事件。我正在分配一个类方法来处理onFocus事件。在事件处理程序中,我需要访问类实例和事件对象本身。Mootools - 绑定到类实例和访问事件对象
但是,当我使用.bind(this)时,我不能再获取事件对象,因为范围现在已更改为类实例。如果我不使用.bind(this),我可以访问事件对象,但不能访问类实例。
我确定有一个解决方案,但我一直无法弄清楚这一点。有任何想法吗?
谢谢。
new Class({
handleComponentFocus : function() {
// this refers to the class instance
// I would also like to get the event information as well, but can't now that the scope has been changed
}.bind(this)
this.pickList = new BasePickList({
onFocus : this.handleComponentFocus
});
})