Created
June 9, 2017 13:12
-
-
Save yunusga/5dc5d9b428f15884225405e57f49cfe5 to your computer and use it in GitHub Desktop.
Multi-floor bootstrap modal windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var modalsOpened = 0, | |
openedModalZIndex = 0, | |
$currentModal = null; | |
$('.modal') | |
.on('show.bs.modal', function(e) { | |
$currentModal = $(e.delegateTarget); | |
openedModalZIndex = $currentModal.css('z-index') + modalsOpened; | |
$currentModal.css({ | |
zIndex : openedModalZIndex | |
}); | |
modalsOpened++; | |
}) | |
.on('hidden.bs.modal', function() { | |
if (modalsOpened > 1) { | |
$('body').addClass('modal-open'); | |
} | |
openedModalZIndex--; | |
modalsOpened--; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment