From b74ff2da782bad49b738e6e6f4885f99db7ebb1e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 14 Jan 2025 20:01:48 +0100 Subject: [PATCH] Implemented reinitialisation of event listeners --- app/static/js/navigation.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/static/js/navigation.js b/app/static/js/navigation.js index ac76fbf..8591977 100644 --- a/app/static/js/navigation.js +++ b/app/static/js/navigation.js @@ -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);