fix(zopk): Naprawa inicjalizacji grafu relacji
Problem: D3.js ładowane przez base.html PO bloku extra_js,
więc initGraph() była wywoływana gdy D3 jeszcze nie istniało.
Rozwiązanie: użycie window.addEventListener('load', ...)
zamiast natychmiastowego sprawdzenia typeof d3.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
85c3f75e9b
commit
36d24d1735
@ -318,15 +318,15 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
// Wait for D3 to load
|
||||
if (typeof d3 === 'undefined') {
|
||||
const script = document.createElement('script');
|
||||
script.src = 'https://d3js.org/d3.v7.min.js';
|
||||
script.onload = initGraph;
|
||||
document.head.appendChild(script);
|
||||
} else {
|
||||
initGraph();
|
||||
}
|
||||
// D3 is loaded by base.html AFTER this block, so we need to wait
|
||||
// Use window.onload to ensure D3 script from base.html is fully loaded
|
||||
window.addEventListener('load', function() {
|
||||
if (typeof d3 !== 'undefined') {
|
||||
initGraph();
|
||||
} else {
|
||||
console.error('D3.js not loaded!');
|
||||
}
|
||||
});
|
||||
|
||||
let simulation, svg, g, link, node, zoom;
|
||||
let currentNodes = [];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user