Solved close modals bug

This commit is contained in:
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) {
// Schließe alle offenen Modals
closeAllModals();
// Setze den Titel
document.getElementById('dynamicModalLabel').innerText = subitem.description;
@@ -76,3 +79,22 @@ function openDynamicPopup(subitem) {
const modal = new bootstrap.Modal(document.getElementById('dynamicModal'));
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 = '';
}