if you still need the performance of event delegation (live), you
should make the handling function separately and assign it using
several "live"s. eg:

function handleStuff(e) {
  // do things
}

$("div > p, #nav a").live("click", handleStuff).live("keydown",
handleStuff);

be aware that live() doesnt "officially" support a lot of events
(blur, focus, mouseenter, mouseleave, change, submit)...though they
will work in some browsers (tested in Minefield nightlies)...so you'll
still need bind() for those until they work out all the cross-browser
issues for them.

On Apr 14, 5:21 pm, James <james.gp....@gmail.com> wrote:
> $('.things').bind('focus change click', function() {
>      // your code here
>
> });
>
> (Note that this doesn't work for $.live(), as you can only bind one
> event for that.)
>
> On Apr 14, 10:40 am, Tom Worster <f...@thefsb.org> wrote:
>
> > i can assign a handler to one event type thus:
>
> > $('.things').focus(function(){
> >     $(this).data('foo', true);
> >     ...
>
> > });
>
> > if i want to assign the same handler to several events, say focus, change,
> > and click, what's the tidy way to write it [assuming my handler wants to
> > access $(this)]?

Reply via email to