Bug Tracker

Modify

Ticket #923 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

Global triggers can execute handlers multiple times

Reported by: jchaffer@… Owned by:
Priority: minor Milestone: 1.1.3
Component: event Version:
Keywords: Cc:
Blocking: Blocked by:

Description (last modified by brandon) (diff)

If two global handlers for the same event type are attached to the same element, the handlers will each fire twice. For example:

$('#foo').ajaxComplete(function() {

alert('foo');

}); $('#foo').ajaxComplete(function() {

alert('bar');

});

When a request completes, we will see four alerts, not two.

This is due to the flow of "trigger: function(type, data, element)". This calls .trigger() on each element, which in turn calls each handler. To fix, the function probably needs to first winnow the matched elements down to a unique set before the recursive call to .trigger().

Change History

comment:1 Changed 6 years ago by brandon

  • need set to Test Case
  • Milestone set to 1.1.3

comment:2 Changed 6 years ago by brandon

  • Status changed from new to closed
  • Resolution set to fixed
  • Description modified (diff)

This is now fixed in Rev [2011].

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.