Solved close modals bug

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-09 15:38:48 +01:00
parent e303968ca5
commit a9fcd4b6de
2 changed files with 23 additions and 1 deletions

View File

@ -1,4 +1,7 @@
function openDynamicPopup(subitem) { function openDynamicPopup(subitem) {
// Schließe alle offenen Modals
closeAllModals();
// Setze den Titel // Setze den Titel
document.getElementById('dynamicModalLabel').innerText = subitem.description; document.getElementById('dynamicModalLabel').innerText = subitem.description;
@ -76,3 +79,22 @@ function openDynamicPopup(subitem) {
const modal = new bootstrap.Modal(document.getElementById('dynamicModal')); const modal = new bootstrap.Modal(document.getElementById('dynamicModal'));
modal.show(); modal.show();
} }
function closeAllModals() {
const modals = document.querySelectorAll('.modal.show'); // Alle offenen Modals finden
modals.forEach(modal => {
const modalInstance = bootstrap.Modal.getInstance(modal);
if (modalInstance) {
modalInstance.hide(); // Modal ausblenden
}
});
// Entferne die "modal-backdrop"-Elemente
const backdrops = document.querySelectorAll('.modal-backdrop');
backdrops.forEach(backdrop => backdrop.remove());
// Entferne die Klasse, die den Hintergrund ausgraut
document.body.classList.remove('modal-open');
document.body.style.overflow = '';
document.body.style.paddingRight = '';
}

View File

@ -32,7 +32,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" onclick="closeAllModals()">Close</button>
</div> </div>
</div> </div>
</div> </div>