Skip to main content

Bug Tracker

Side navigation

#10886 closed bug (worksforme)

Opened November 24, 2011 01:57PM UTC

Closed November 23, 2012 10:22PM UTC

Last modified November 23, 2012 10:23PM UTC

$(document).trigger() crashes jquery

Reported by: Owned by:
Priority: low Milestone:
Component: event Version: 1.7.1
Keywords: ie6 ie7 Cc:
Blocked by: Blocking:

We have tried jQuery 1.7 and 1.7.1 and both exhibit a problem that we do not have with jQuery 1.6.4.

If we trigger any events in a certain namespace, e.g






we get this error on line 3175 of the 1.7.1 unminified version:

"elem[type] is not a function"

We don't seem to have any problems on any other namespace, so I am not sure what the issue is really.

Attachments (0)
Change History (15)

Changed November 24, 2011 08:29PM UTC by dmethvin comment:1

owner: →
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: Open the link and click to "Fork" (in the top menu) to get started.

Changed November 28, 2011 12:39PM UTC by anonymous comment:2

I understand the need for a cut-down test case, but to be honest this is a huge piece of code and, try as I might, I cannot get it into a manageable jsFiddle test case. You can, however, replicate it online by going to and logging on with a user id and password of "demo".

You can then click on the large cog icon/button at the top right hand side of the screen. The button will have a tooltip of "Switch to RGD mode". When you click this button the screen will change after downloading various resources. If you do this in Firefox with firebug enabled, you can just replicate the error by executing $(document).trigger('RGD.changesApplied'). In reality the user sees the error by dragging and dropping templates into the viewport.

Changed November 28, 2011 02:15PM UTC by dmethvin comment:3

Do you have a global variable named RGD perhaps?

Changed November 29, 2011 11:24AM UTC by Kevin Turner comment:4

Yes, there is a global object called RGD. However, there are several global objects (like RNS for example) and we can trigger events in their namespace OK. For example, I can do this: $(document).trigger('RNS.something')

but I cannot do this


although it is OK up to and including version 1.6.4.

What sort of property in the RGD object might cause this to screw up now when it didn't before?

Changed November 29, 2011 03:12PM UTC by dmethvin comment:5

If you had a test case it might be possible to isolate the why, but we generally don't want to get into debugging someone's site. I suspect that there is an RGD on document and .trigger() is trying to call that. As documented, if you don't want that behavior call .triggerHandler(), which also won't bubble to window. Can you give that a try? If you can create a reduced test case I'd still like to see it.

Changed November 29, 2011 04:19PM UTC by Kevin Turner comment:6

I can confirm that .triggerHandler() works perfectly.

Is there anything I cando to help you work out why trigger doesn't work? I amhappy to continue with triggerHandler but I think it would be useful to know what went wrong. I have tried a cut down example with just the RGD object present but it seems OK - so some piece of code embedded in the application is cauing it. Trying to find it will be a nightmare without some idea what to look for. I am happy to debug my own application if required.

Changed November 30, 2011 03:34AM UTC by dmethvin comment:7

component: unfiledevent
priority: undecidedlow
status: pendingopen

I'll mark this open so it won't be auto-closed but I don't have the time at the moment to debug it. To me it seems like the RNS object should cause the same error, not sure why they are different but I haven't looked at the code.

Changed December 22, 2011 04:34AM UTC by anonymous comment:8

This test case shows the error:, use real firebug, not lite.

Changed December 22, 2011 10:05AM UTC by Kevin Turner comment:9

Yes, that rather simple test case does show the bug in a firebug console. Thanks. I guess in my case there is a scenario where the object has no properties. Triggering an event with that object name as the namespace causes the error - but only in 1.7.1.

Changed January 30, 2012 05:42PM UTC by borgar comment:10

What is happening is that .trigger() tries to execute the "default action" of the element after having bubbled the event: elem[ type ](); (event.js#L372)

However, the checking that is done prior is whether the property exists on the element and is truthy, but not whether it actually is a function. So: if ( ... && elem[ type ] && ... ) (event.js#L361)

Thus, all events that share a type-name with a non-function member on the element will crash!

An extremely reduced example would be: $('<a href="#"><a>').trigger('href');

And another jsfiddle: - again, use real firebug, not lite.

Changed March 03, 2012 10:28PM UTC by dmethvin comment:11

keywords: → ie6 ie7

If we could reliably detect whether a property was callable, we could fix this. Unfortunately, IE6/7 return for example, typeof link.focus == "object" rather than saying it's a function. I suppose we could see if it's either an object or a function, that would at least limit the damage but as I understand the OP report it would not fix his problem.

Changed June 26, 2012 01:44AM UTC by dmethvin comment:12

milestone: None2.0

Changed November 23, 2012 09:49PM UTC by david71rj comment:13

Seems solved in the edge.

Changed November 23, 2012 10:22PM UTC by dmethvin comment:14

resolution: → worksforme
status: openclosed

Not quite sure what status to use for resolution but the important thing (to me!) is that the ticket is closed.

Changed November 23, 2012 10:23PM UTC by dmethvin comment:15

milestone: 2.0