This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes stopping event propagation best practice (jQuery) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "stopping event propagation best practice (jQuery)" Watch "stopping event propagation best practice (jQuery)" New topic
Author

stopping event propagation best practice (jQuery)

Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 79
I have some code similar to this:



The problem is that the custom event 'myCustomEvent' is getting triggered once for the element that is actually bound to it and once for each of its children. I am trying to implement a publish/subscribe model here where I trigger the custom event and whoever wants to can respond to it. What is the best practice for getting the event to trigger only for the element that was actually bound to it?

Thanks,
Rob
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Return false or call event.stopPropagation().


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 79
Bear Bibeault wrote:Return false or call event.stopPropagation().


Unfortunately, that doesn't work.

Thanks,
Rob
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stopping event propagation best practice (jQuery)
 
Similar Threads
change event is firing twice
jQuery.getJSON callback not executing
Problem with custom events in jQuery
console.log function not working.
Not able to hide a sentence using jquery