twitter/bootstrap — pull request #5318 by jschr (2012-09-27 14:20:37+00:00)
Title: Use .triggerHandler() instead of .trigger() for customer events.

For custom events (hide, show, closed, etc..) it is more desirable to not propagate the event by default. This causes many problems with nested components such as tabs within tabs or tabs within modals, etc.

The reason this is problematic is if I am watching the shown event on a modal that has tabs inside, clicking on the inner tab will cause the modal to receive a shown event. This [fiddle](http://jsfiddle.net/jschr/7vTVJ/2/) shows the issue. Opening up the console will show that clicking on a tab triggers the modal's shown event as well.

The solution is to call stopPropagation() on the event which could be done in the event handler itself but this can automatically be done with the [triggerHandler](http://api.jquery.com/triggerHandler/) function instead of trigger. I can't think of a good use case why you would want these events to propagate through the DOM as it will almost always cause undesired behaviour.

See this jquery issue as a reference: http://bugs.jquery.com/ticket/10699