Refactor: Extract sidebar into a reusable component #4
@@ -1,7 +1,8 @@
|
||||
// views/components/sidebar/sidebar.js
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
initSidebar();
|
||||
});
|
||||
// NOTE: This script is always loaded dynamically by sidebarLoader.js AFTER
|
||||
// the sidebar HTML has already been injected into #sidebar-container.
|
||||
// DOMContentLoaded has already fired at this point, so we must call
|
||||
// initSidebar() directly — NOT inside a DOMContentLoaded listener.
|
||||
|
||||
function initSidebar() {
|
||||
const floatingMenuBtn = document.getElementById("floatingMenuBtn");
|
||||
@@ -67,3 +68,6 @@ function initSidebar() {
|
||||
lastScrollY = window.scrollY;
|
||||
});
|
||||
}
|
||||
|
||||
// Call directly — sidebar HTML is already in DOM when this script executes
|
||||
initSidebar();
|
||||
|
||||
Reference in New Issue
Block a user