diff --git a/static/js/graph.js b/static/js/graph.js index c00f182..641a99f 100644 --- a/static/js/graph.js +++ b/static/js/graph.js @@ -74,6 +74,7 @@ class GraphManager { // Manual refresh button for polling optimization this.manualRefreshButton = null; + this.manualRefreshHandler = null; // Store the handler this.options = { nodes: { @@ -284,6 +285,10 @@ class GraphManager { // Manual refresh button - handler will be set by main app this.manualRefreshButton = document.getElementById('graph-manual-refresh'); + // If a handler was set before the button existed, attach it now + if (this.manualRefreshButton && this.manualRefreshHandler) { + this.manualRefreshButton.addEventListener('click', this.manualRefreshHandler); + } } /** @@ -291,6 +296,8 @@ class GraphManager { * @param {Function} handler - Function to call when manual refresh is clicked */ setManualRefreshHandler(handler) { + this.manualRefreshHandler = handler; + // If the button already exists, attach the handler if (this.manualRefreshButton && typeof handler === 'function') { this.manualRefreshButton.addEventListener('click', handler); }