File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -401,3 +401,33 @@ $(document).ready(function() {
401401 // Data Tables
402402 new DataTable ( '.dataTables' ) ;
403403} ) ;
404+
405+ /*
406+ |---------------------------------------------------------------
407+ | Nested Modal Fix for Bootstrap/AdminLTE
408+ | Prevents parent modals from closing when a child modal closes
409+ |---------------------------------------------------------------
410+ */
411+ $ ( document ) . on ( 'show.bs.modal' , '.modal' , function ( ) {
412+ // How many modals are currently visible?
413+ const visibleModals = $ ( '.modal:visible' ) . length ;
414+
415+ // Increase z-index for each new modal
416+ const zIndex = 1040 + ( 10 * visibleModals ) ;
417+ $ ( this ) . css ( 'z-index' , zIndex ) ;
418+
419+ // Delay required because Bootstrap inserts backdrop asynchronously
420+ setTimeout ( ( ) => {
421+ $ ( '.modal-backdrop' ) . not ( '.modal-stack' )
422+ . css ( 'z-index' , zIndex - 1 )
423+ . addClass ( 'modal-stack' ) ; // mark backdrops so they aren't reset
424+ } , 0 ) ;
425+ } ) ;
426+
427+ // Restore modal-open class when closing a child modal
428+ $ ( document ) . on ( 'hidden.bs.modal' , '.modal' , function ( ) {
429+ if ( $ ( '.modal:visible' ) . length > 0 ) {
430+ // Ensure background scroll remains locked
431+ $ ( 'body' ) . addClass ( 'modal-open' ) ;
432+ }
433+ } ) ;
You can’t perform that action at this time.
0 commit comments