Bug Tracker

Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#923 closed bug (fixed)

Global triggers can execute handlers multiple times

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

Description (last modified by brandon)

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

comment:1 Changed 13 years ago by brandon

Milestone: 1.1.3
need: Test Case

comment:2 Changed 13 years ago by brandon

Description: modified (diff)
Resolution: fixed
Status: newclosed

This is now fixed in Rev [2011].

Note: See TracTickets for help on using tickets.