diff --git a/js/app.js b/js/app.js index 7f2d7300..be2d0963 100644 --- a/js/app.js +++ b/js/app.js @@ -404,30 +404,54 @@ $(document).ready(function() { /* |--------------------------------------------------------------- - | Nested Modal Fix for Bootstrap/AdminLTE - | Prevents parent modals from closing when a child modal closes + | Nested Modal Fix for ITFlow AJAX Modals + | Each modal gets a unique container, parent modals remain open |--------------------------------------------------------------- */ -$(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); +(function() { + if (!window.createAjaxModal) return; - // 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); -}); + // Keep original function just in case + const originalCreateAjaxModal = window.createAjaxModal; + + window.createAjaxModal = function(contentHtml) { + // Generate a unique ID for this modal + const modalId = 'ajaxModal_' + Date.now(); + + // Create a new modal container + const $modal = $('