I recently created an plugin/extension for jQuery to use the following
syntax for binding events.

$('input').bind('mouseover focus', fn);

So you can bind multiple event types to the same function quickly. It also
applies to .one and .unbind.

However, this got me thinking about writing a plugin that would allow us to
add new event types ... like mouseenter and mouseleave. So instead of using
.hover, you could do this:

$(...).bind('mouseenter', fn);

or

$(...).bind('mouseenter', fn1).bind('mouseenter', fn2);

or

$(...).unbind('mouseenter', fn1);

or

$(...).trigger('mouseenter');

etc...


So I'm curious about what the jQuery community thinks about this idea? I've
built out a proof-of-concept but it is by no means production ready. You can
see it in action here:
http://www.brandonaaron.net/jquery/plugins/events_extension/test/test.html

We could also hook up the mousewheel event in the same way.

$(...).bind('mousewheel', fn);

Are there other events that could be added/normalized with this plugin?



BTW ... Here is the blog post about binding multiple event types:
http://blog.brandonaaron.net/2007/06/05/bind-multiple-events-simultaneously-with-jquery/

--
Brandon Aaron

Reply via email to