Skip to main content

Bug Tracker

Side navigation

#9911 closed bug (invalid)

Opened July 26, 2011 01:01PM UTC

Closed July 26, 2011 01:43PM UTC

Last modified April 12, 2013 08:21PM UTC

Undelegate will not work when selector is class name.

Reported by: rosenkonstantinov@gmail.com Owned by:
Priority: low Milestone: None
Component: event Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

It seems that as of jQuery 1.6.x undelegate will not work if selector is a class name. (this is working with 1.5.2)

Tested on Chorme 12.0.742.122 and Firefox 5.0.

Sample repro http://jsfiddle.net/njrNw/7/. Clicking on the button will not remove the previous delegate causing multiple executions of the click handler.

Attachments (0)
Change History (3)

Changed July 26, 2011 01:43PM UTC by timmywil comment:1

component: unfiledevent
priority: undecidedlow
resolution: → invalid
status: newclosed

Changed July 26, 2011 02:31PM UTC by dmethvin comment:2

OP, you are confusing HTML classes with jQuery event namespaces. This example with namespaces works fine.

http://jsfiddle.net/dmethvin/njrNw/10/

Changed April 12, 2013 08:21PM UTC by anonymous comment:3

<p>
The new on() replacement for delegate also will not undelegate.
</p>

<div id="container">
        <button type="button" class="b">Click me twice</button>
</div>
function attach() {
    var $con = $("#container").on("click", ".b",
             function() {
                 console.log("click");
                 attach();
             }
        );
}    

attach();