[jQuery] jQuery Global Events Slightly Askew

[jQuery] jQuery Global Events Slightly Askew

So I noticed something recently when I found out about, and played
around with, those zany global event triggers. If you add two different
events of the same type to the same element, when you call the global
event trigger for that type, each event will get called twice.
Example:
func1 = function() { window.alert("1"); };
func2 = function() { window.alert("2"); };
$('#box').click(func1).click(func2);
jQuery.event.trigger('click');
Problem:
You should see "1" and "2" both alerted twice.
Luckily there's a quick and painless fix to this. Inside the
event.trigger function if the line
var g = this.global[type];
is changed to
var g = jQuery.map(this.global[type],"a");
jQuery.map will make sure there are no duplicate elements in the list
before it is iterated through to call the events. Pretty esoteric bug
but a bug nonetheless.
--
blair
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/