Bug Tracker

Modify

Ticket #9911 (closed bug: invalid)

Opened 22 months ago

Last modified 5 weeks ago

Undelegate will not work when selector is class name.

Reported by: rosenkonstantinov@… Owned by:
Priority: low Milestone: None
Component: event Version: 1.6.2
Keywords: Cc:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 22 months ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to event

comment:2 Changed 22 months ago by dmethvin

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

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

comment:3 Changed 5 weeks ago by anonymous

<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();

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.