Skip to content

Instantly share code, notes, and snippets.

@yunusga
Created June 9, 2017 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yunusga/5dc5d9b428f15884225405e57f49cfe5 to your computer and use it in GitHub Desktop.
Save yunusga/5dc5d9b428f15884225405e57f49cfe5 to your computer and use it in GitHub Desktop.
Multi-floor bootstrap modal windows
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