Skip to main content

Bug Tracker

Side navigation

#3538 closed bug (fixed)

Opened October 28, 2008 08:51PM UTC

Closed January 08, 2009 10:23PM UTC

.unbind() on multiple event types only unbinds first type

Reported by: JonBob Owned by: flesler
Priority: major Milestone: 1.3
Component: event Version: 1.2.6
Keywords: unbind Cc: JonBob, kswedberg
Blocked by: Blocking:

Observed in Firefox 3 Mac.

According to the source code comments for .remove():

// Handle multiple events seperated by a space

// jQuery(...).unbind("mouseover mouseout", fn);

This does not appear to actually work; the second event type supplied does nothing. Steps to reproduce in Firebug:

Environment: any page with a visible element (we'll call it <div id="test"></div>) and jQuery loaded.

$('#test').click(function() { console.log('click'); });

$('#test').dblclick(function() { console.log('dblclick'); });

Now clicks and double-clicks will log the appropriate messages.

$('#test').unbind('click dblclick');

Clicks no longer log messages; double-clicks incorrectly do, though.

Attachments (0)
Change History (3)

Changed October 28, 2008 09:21PM UTC by JonBob comment:1

Okay, here's the problem.

Line 1941 of jquery.js:

for ( handler in events[type] )

The variable handler is being reused here. Not a problem if the loop is only executed once, but if there's a second pass through, this clobbers the parameter handler and causes the other unbinds to fail.

Changed November 29, 2008 04:29PM UTC by flesler comment:2

cc: → JonBob, kswedberg
need: ReviewPatch
owner: brandonflesler
priority: minormajor
status: newassigned

Will fix this asap.

Changed January 08, 2009 10:23PM UTC by flesler comment:3

resolution: → fixed
status: assignedclosed

Fixed at [6068].

Refactored unbind tests at [6069], including one for this issue.