Ticket #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: | ||
| 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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
