Skip to main content

Bug Tracker

Side navigation

#6738 closed bug (invalid)

Opened June 28, 2010 03:31PM UTC

Closed March 31, 2011 07:52PM UTC

Global events that are namespaced do not trigger correctly.

Reported by: swalke16 Owned by:
Priority: low Milestone:
Component: event Version: 1.4.2
Keywords: global namespaced events Cc:
Blocked by: Blocking:

If I have a global event that is namespaced such as in the following gist:

It will never be triggered.

Looking at the code, the $.bind function keeps track of all events used in a global array in this line:

Keep track of which events have been used, for global triggering[ type ] = true;

Firstly it seems like this should be used only for global events, but in any case the type used here is without the namespace.

When triggering the event the following code in the trigger function will not work:

Only trigger if we've ever bound an event for it

if ([ type ] ) {

jQuery.each( jQuery.cache, function() {

if ( &&[type]) {

jQuery.event.trigger( event, data,

this.handle.elem );




First problem is that in the first line of this code, the type value still contains the namespace and so won't match the way that bind was storing this value in the global array without namespace.

If we simply fix that problem, the event will be fired, but exposes another problem in that the if statement inside the anonymous function passed to the .each() does not check to see if the namespace matches before triggering the event.

This clearly seems like a bug that needs to be fixed.

Attachments (0)
Change History (3)

Changed November 03, 2010 05:08AM UTC by boushley comment:1

Here is a fiddle that is basically the test case from the gist, although I removed the animations and things to make it a bit simpler. I think this bug is valid, however I think it is probably low priority as namespaced events firing on the global context probably don't affect a large portion of the user base.

Changed November 03, 2010 06:19PM UTC by SlexAxton comment:2

priority: → low
status: newopen

Sounds like a fair assessment, thanks for the fiddle. Adding.

Changed March 31, 2011 07:52PM UTC by dmethvin comment:3

resolution: → invalid
status: openclosed

jQuery doesn't support external calls to jQuery.event.trigger() in order to trigger a global event. That is not a documented interface.