title: jQuery prevent all event bubbling
body: <p>I'm using jQuery with it's widget factory and using custom events to handle events in my application.</p>
  
  <p>This means that all my event binding looks a lot like:</p>
  
  <pre><code>//...in the widget factory code
  
  $(this.element).addClass('customEventClass');
  $(this.element).bind('mysite.loadNextPage', $.proxy(this, 'loadNextPage');
  </code></pre>
  
  <p>and the events are triggered by doing:</p>
  
  <pre><code>$('.customEventClass').trigger('mysite.loadNextPage');
  </code></pre>
  
  <p>Because the events are directly bound to the elements that need to receive them, I don't need to have these custom events to bubble up through the DOM. I know I can check whether the even has bubbled up or not by doing this in the event handler code:</p>
  
  <pre><code>if (event.target != event.currentTarget) {
      event.stopPropagation();
      event.preventDefault();
      return;
  }
  </code></pre>
  
  <p>But at the moment because most of the elements that are listening for the custom events don't have a handler registered for 'mysite.loadNextPage' there are 51 events generated where only 1 actually does anything. Is there a way to either:</p>
  
  <ol>
  <li>tell jQuery not to bubble these events at all or</li>
  <li>Add a default 'stop propagation' handler to all DOM objects that have class 'customEventClass' to stop them from bubbling up an event that they don't have a specific handler for.</li>
  </ol>
  
  <p>Or are there any other good practices for only triggering events on elements that are interesting in those events, rather than having lots of events be triggered for elements that aren't interested in those events.</p>