Created
August 5, 2015 18:03
-
-
Save skunkworker/809059ba8d9b919ec769 to your computer and use it in GitHub Desktop.
Multiple Bootstrap modals
This file contains 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
$(document).ready(function() { | |
$('#openBtn').click(function(){ | |
$('#myModal').modal({show:true}) | |
}); | |
$('.modal').on('hidden.bs.modal', function( event ) { | |
$(this).removeClass( 'fv-modal-stack' ); | |
$('body').data( 'fv_open_modals', $('body').data( 'fv_open_modals' ) - 1 ); | |
}); | |
$( '.modal' ).on( 'shown.bs.modal', function ( event ) { | |
// keep track of the number of open modals | |
if ( typeof( $('body').data( 'fv_open_modals' ) ) == 'undefined' ) | |
{ | |
$('body').data( 'fv_open_modals', 0 ); | |
} | |
// if the z-index of this modal has been set, ignore. | |
if ( $(this).hasClass( 'fv-modal-stack' ) ) | |
{ | |
return; | |
} | |
$(this).addClass( 'fv-modal-stack' ); | |
$('body').data( 'fv_open_modals', $('body').data( 'fv_open_modals' ) + 1 ); | |
$(this).css('z-index', 1040 + (10 * $('body').data( 'fv_open_modals' ))); | |
$( '.modal-backdrop' ).not( '.fv-modal-stack' ).css( 'z-index', 1039 + (10 * $('body').data( 'fv_open_modals' ))); | |
$( '.modal-backdrop' ).not( 'fv-modal-stack' ).addClass( 'fv-modal-stack' ); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment