This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Problem with custom events in jQuery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problem with custom events in jQuery" Watch "Problem with custom events in jQuery" New topic

Problem with custom events in jQuery

Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 83
I created the following test app to debug some jQuery code I am developing. When I click on the button, I get the first debug message ("ever here"), but not the second ("foo"). I can't figure out what I am doing wrong here. Please advise.


Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You are triggering the event on an element that is not listening for it.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Remember that events, even custom events, bubble up the DOM tree. So you must trigger events on the listening element or one of its descendants.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Problem with custom events in jQuery
jQuery in Action, 3rd edition