Skip to content

Instantly share code, notes, and snippets.

@IAMIronmanSam
Created June 6, 2016 21:42
Show Gist options
  • Select an option

  • Save IAMIronmanSam/187ecd7344c04d0ce1fb10303a99ea56 to your computer and use it in GitHub Desktop.

Select an option

Save IAMIronmanSam/187ecd7344c04d0ce1fb10303a99ea56 to your computer and use it in GitHub Desktop.
Stack more than one bootstrap modal dialog
function stackBootstrapModal(){
$(document).on('show.bs.modal', '.modal', function (event) {
var zIndex = 1040 + (10 * $('.modal:visible').length);
$(this).css('z-index', zIndex);
setTimeout(function() {
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
});
$(document).on('hidden.bs.modal', '.modal', function () {
$('.modal:visible').length && $(document.body).addClass('modal-open');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment