Trying to encapsulate programming logic into objects, I hit a snag when dealing with event callbacks in javascript. Using the prototype library I use the Object.extend method to create my own objects, which contain their own event handlers. When the event handler fires, the reference to the object instance has been lost, however, so the code does not work anymore.
The gentleman in this blog entry found the solution: the callback needs to be passed as event listener like so
this.callback.bindAsEventListener(this)and all is well.