[Bug 16491] Add simpler and better event registration system

https://www.w3.org/Bugs/Public/show_bug.cgi?id=16491

Glenn Maynard <glenn@zewt.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |glenn@zewt.org

--- Comment #3 from Glenn Maynard <glenn@zewt.org> ---
For reference, another event interface is Prototype's Event.on:
http://prototypejs.org/doc/latest/dom/Event/

In particular, it returns an object which can later be used to remove the event
handler, so you don't need to keep a reference to the function.  For example:

this.handler1 = element.on("click", function(e) { });
...
this.handler1.stop();

I found this handy when I used it, though these days I find this pattern to
work fine:

foo = function()
{
    this.onclick = this.onclick.bind(this);
    foo.addEventListener("click", this.onclick, false);
    ...
    foo.removeEventListener("click", this.onclick, false);
}
foo.prototype.onclick = function(e) { ... }

(where by "fine" I mean it works well enough, even if it's a little uncosmetic,
that I'm not desperately searching for something better and I'm not sure
Prototype's approach is actually better).

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Saturday, 5 January 2013 00:11:02 UTC