Multiple eventName's for Event observe?

23 views
Skip to first unread message

Ngan Pham

unread,
Oct 22, 2009, 1:50:36 PM10/22/09
to Prototype: Core
It would be nice if Event#observe's eventName argument was able to take an array, or perhaps a comma delimited string so that it can attach to multiple events in one call:

Event.observe(something, 'keyup,mouseup', this.blah.bind(this));
or
Event.observe(something, ['keyup', 'mouseup'], this.blah.bind(this));

Allen Madsen

unread,
Oct 22, 2009, 2:12:44 PM10/22/09
to prototy...@googlegroups.com
I would prefer something more like this:
http://gist.github.com/166475

I think it is a rare use case that you would apply the same action to
many events on the same object. However, I think it is much more
common to apply multiple actions to events on the same object at one
time.

Of the two solutions you mention though, I would prefer the first.

Allen Madsen
http://www.allenmadsen.com

Deadelus

unread,
Nov 4, 2009, 4:10:55 AM11/4/09
to Prototype: Core
I have to agree with Allen on this one. The mentioned usage would work
perfectly for me.

On Oct 22, 7:12 pm, Allen Madsen <bla...@gmail.com> wrote:
> I would prefer something more like this:http://gist.github.com/166475
>
> I think it is a rare use case that you would apply the same action to
> many events on the same object. However, I think it is much more
> common to apply multiple actions to events on the same object at one
> time.
>
> Of the two solutions you mention though, I would prefer the first.
>
> Allen Madsenhttp://www.allenmadsen.com
Reply all
Reply to author
Forward
0 new messages