View Full Version : EventManager "on" question

31 Jan 2007, 4:31 PM
The docs:

public function on(Object element, String eventName, Function fn, Object scope, boolean override)

Would I be able to pass an array somehow to this, to eliminate the need for the following code?

/* mouse listeners [Could these be combined somehow?] */
getEl("gamefield").on("click", this.mouseHandler, this);
getEl("gamefield").on("mousemove", this.mouseHandler, this);
getEl("gamefield").on("mouseout", this.mouseHandler, this);

or , more likely, is there a better way to accomplish what I am trying to do?

Thank you.

John T.

31 Jan 2007, 5:17 PM
Oh, in case any were wondering, yes I tried this. It threw an error.

1 Feb 2007, 1:09 AM
No, you can't do that, but it might save some client code if you could hook >1 event up to the same handler.

Submit a sourceforge enhancement request to te YUI team... the Ext event system is built on YUI, so that would need to handle this pattern.