diff --git a/static/js/update_mindmap.js b/static/js/update_mindmap.js index ed49cd0..083e407 100644 --- a/static/js/update_mindmap.js +++ b/static/js/update_mindmap.js @@ -182,6 +182,23 @@ async function loadMindmapData(nodeId = null) { } } +/** + * Zerstört eine Cytoscape-Instanz sicher + * @param {Object} instance - Die zu zerstörende Cytoscape-Instanz + */ +function destroyCytoscapeInstance(instance) { + if (instance && typeof instance.destroy === 'function') { + try { + // Event-Listener entfernen + instance.removeAllListeners(); + // Instanz zerstören + instance.destroy(); + } catch (e) { + console.error('Fehler beim Zerstören der Cytoscape-Instanz:', e); + } + } +} + // Funktion zum Initialisieren der Mindmap async function initializeMindmap() { try {