Implemented reinitialisation of event listeners

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-14 20:01:48 +01:00
parent 066f10edfc
commit b74ff2da78

View File

@ -9,6 +9,7 @@ document.addEventListener('DOMContentLoaded', () => {
function onMouseEnter() {
clearTimeout(timeout);
openMenu(item, isTopLevel);
refreshEventListeners();
}
function onMouseLeave() {
@ -32,10 +33,18 @@ document.addEventListener('DOMContentLoaded', () => {
} else {
openMenu(item, isTopLevel);
}
refreshEventListeners();
});
});
}
function refreshEventListeners() {
const updatedMenuItems = document.querySelectorAll('.nav-item.dropdown');
const updatedSubMenuItems = document.querySelectorAll('.dropdown-submenu');
addMenuEventListeners(updatedMenuItems, true);
addMenuEventListeners(updatedSubMenuItems, false);
}
addMenuEventListeners(menuItems, true);
addMenuEventListeners(subMenuItems, false);