Is there a way to utilize a bound event handler in prototype while maintaining the "this" context? It seems that doing so disrupts the default binding provided by prototype for event handlers.
According to the documentation:
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).
This is exactly what I need. However, once I bind the function to my own context, is there a way to access the "element being observed" in any manner? Using e.element() may not give me the observed element if it is a child element:
initialize: function() {
Event.observe('foo', 'click', this.addItem.bind(this));
},
...
addItem: function(e) {
e.element() // -> clicked element, not necessarily the observed element
}
I am aware of bindAsEventListener option but it doesn't seem necessary here, and I'm unsure how to access the targeted element once the function is bound.
Additionally, I know that there's an e.currentTarget property, but does it work in IE?