From c005ad9df7cbb92c2c9a0c2ef953e849b05ea0b2 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 10 Jan 2021 18:50:20 +0100 Subject: [PATCH] Fix referenceError --- assets/js/main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 6cc8b207..11acbd9a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -5,11 +5,6 @@ document.querySelectorAll(".onclick-select").forEach((element) => { // Navbar dropdowns const navSections = document.querySelectorAll(".nav-details"); -navSections.forEach(navSection => { - navSection.addEventListener("toggle", navSectionsToggle); -}); -document.addEventListener("click", navSectionsClose); - const navSectionsToggle = () => { // When opening next dropdown, hide previous if (this.open) { @@ -21,6 +16,12 @@ const navSectionsToggle = () => { } } +navSections.forEach(navSection => { + navSection.addEventListener("toggle", navSectionsToggle); +}); +document.addEventListener("click", navSectionsClose); + + const navSectionsClose = (event) => { // Hide all dropdowns when clicking in different place if (