twitter/bootstrap — Issue #442: 1.3.0: JS: closing an alert-message inside a modal closes modal too.
Author: tubalmartin
Created: 2011-10-18 22:08:30+00:00
State: open

I think the title is self explanatory guys.

I'm using Bootstrap 1.3.0 and default functionality.

I know the reason of that behavior (delegation of the click event up to the body and the impossibility to stop its propagation) and because of that this is my proposal:

Enforce the use of a second class like "modal" in the link responsible for hiding the modal, so that when click event fires you can check if it was originated in a link with class "close modal".

HTML

×

Javascript check

if ( ! $(e.target).is('.close.modal') ) {
return;
}

This is the patch that I use in production right now, working beautifully.
Of course, this should be done on every plugin that uses delegation on the body element.

It's simple but effective.