Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#8555 closed bug (invalid)

When attaching multiple event types with one(), function is called once for each event type

Reported by: goulvench@… Owned by:
Priority: undecided Milestone: 1.next
Component: event Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:

Description

When binding multiple event types at once, the event handler is called once for each event type, instead of one time only as one would expect.

I don't know if this is a bug or a feature, but it might be worth mentioning in the API documentation. Also, explaining how to remove the event handler would be great too, because calling $(this).unbind(e); doesn't remove it from the other event types.

See the simple testcase for yourself.

Change History (4)

comment:1 Changed 8 years ago by goulvench

Using jsFiddle, it appears that all versions of jQuery behave the same in this regard, except 1.2.6 which probably doesn't handle multiple event types being passed as the first argument of one().

comment:2 Changed 8 years ago by dmethvin

Component: unfiledevent
Keywords: needsdocs added
Resolution: invalid
Status: newclosed

We'll document this clearly.

comment:3 Changed 8 years ago by cowboy

You could also try something like this:

https://gist.github.com/894952

comment:4 Changed 8 years ago by kswedberg

Keywords: needsdocs removed
Note: See TracTickets for help on using tickets.