mirror of
https://github.com/itflow-org/itflow
synced 2026-03-16 18:54:51 +00:00
Update app.js
Added fix for nested modals closing parent modals
This commit is contained in:
30
js/app.js
30
js/app.js
@@ -401,3 +401,33 @@ $(document).ready(function() {
|
|||||||
// Data Tables
|
// Data Tables
|
||||||
new DataTable('.dataTables');
|
new DataTable('.dataTables');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------
|
||||||
|
| Nested Modal Fix for Bootstrap/AdminLTE
|
||||||
|
| Prevents parent modals from closing when a child modal closes
|
||||||
|
|---------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
$(document).on('show.bs.modal', '.modal', function () {
|
||||||
|
// How many modals are currently visible?
|
||||||
|
const visibleModals = $('.modal:visible').length;
|
||||||
|
|
||||||
|
// Increase z-index for each new modal
|
||||||
|
const zIndex = 1040 + (10 * visibleModals);
|
||||||
|
$(this).css('z-index', zIndex);
|
||||||
|
|
||||||
|
// Delay required because Bootstrap inserts backdrop asynchronously
|
||||||
|
setTimeout(() => {
|
||||||
|
$('.modal-backdrop').not('.modal-stack')
|
||||||
|
.css('z-index', zIndex - 1)
|
||||||
|
.addClass('modal-stack'); // mark backdrops so they aren't reset
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Restore modal-open class when closing a child modal
|
||||||
|
$(document).on('hidden.bs.modal', '.modal', function () {
|
||||||
|
if ($('.modal:visible').length > 0) {
|
||||||
|
// Ensure background scroll remains locked
|
||||||
|
$('body').addClass('modal-open');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user