I want to be able to use a bound event handler in prototype and retain my "this" context. But doing so seems to destroy the convenient default binding that prototype gives event handlers.
From the docs:
The handler's context (this value) is set to the extended element being observed (even if the event actually occurred on a descendent element and bubbled up).
That's exactly what I want. Once I bind the function to my own context, can I get access to this "element being observed" in any way? I can't depend on e.element() to give me the observed element (it could be a child element):
initialize: function() {
Event.observe('foo', 'click', this.addItem.bind(this));
},
...
addItem: function(e) {
e.element() // -> clicked element, not necessarily observed element
}
I know that there's a bindAsEventListener, but it doesn't seem to be necessary here and I don't see how I can access the targeted element once the function is bound.
I also am aware that there's an e.currentTarget, but that doesn't work in IE, does it?