Bug Tracker

Opened 12 years ago

Closed 12 years ago

#7852 closed bug (wontfix)

Problem of Adding same Event listener Hanlder

Reported by: anonymous Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:


jQuery 1.4.2 line 1663-1664:

      // Add the function to the element's handler list
      handlers.push( handleObj );


      // Add the function to the element's handler list
      var handle_exists = false;
      for (var i = 0; i < handlers.length; ++i) {
        if (handlers[i].guid == handleObj.guid) {
          handle_exists = true;
      if (handle_exists == false) {
        handlers.push( handleObj );

I guess, This jQuery(>=1.4.2)'s problem is caused by changing type of handlers object to array, line 1639.

Change History (2)

comment:1 Changed 12 years ago by anonymous

The reason to post is I want to use jquery.hotkey.js with lastest jQuery. But I faced the problem with jQuery over 1.4.2 version.

sample problem code:

<!DOCTYPE html>
    <script src="./jquery-1.4.2.js"></script>
    <script src="./jquery.hotkeys-0.7.9.js"></script>
      $(function() {
        function output() { console.log(this); }
        $(document.body).bind('keydown', 'j', output);
        $(document.body).bind('keydown', 'k', output);

Opening this and pressing 'j' or 'k', JS console gets document.body three times. To suspend code to the last post one, JS console gets once.

comment:2 Changed 12 years ago by snover

Resolution: wontfix
Status: newclosed

This is, unfortunately, intentional. The same handler can be bound multiple times with different eventData.

Note: See TracTickets for help on using tickets.