qg_java_17137
qg_java_17137

Reputation: 3589

Go-debug-module.js:15 Uncaught Error: Invalid DIV id; could not get element with id: gojs

I use below way to import gojs for my project but failed to find the div.

https://codesandbox.io/s/magical-snowflake-76x31o?file=/src/App.vue

I get error:

Go-debug-module.js:15 Uncaught Error: Invalid DIV id; could not get element with id: gojs

Upvotes: 0

Views: 327

Answers (1)

Nora Söderlund
Nora Söderlund

Reputation: 1191

This happens because your DOM element has not been loaded yet by the browser, but the script has, so the script is executing before the element is available.

It appears that you tried to fix this by using init() but that runs right away as well, instead, add an event listener to the window.onload event: window.onload += init;

Or preferably on DOMContentLoaded as it's executed before external sources has been loaded, unlike window.onload.

document.addEventListener("DOMContentLoaded", init);

Upvotes: 1

Related Questions