Anyone know why this first bit of code works in a javascript file, alone
alert(“Hello! I am an alert box!!”);
…but this second bit of code doesn’t modify the element?
document.getElementById(“atinput_hist”).style.display = “none”;
Dash is cranky when it comes to javascript
Is your post and mine similar? How to trigger a JavaScript function on load?
13 hours and I’m the only reply… Losing faith for my own issue. Sorry I don’t have an answer, but maybe neither of us are the only ones.
Emil
September 17, 2020, 2:32pm
3
How are you calling the JS?
Hi Emil,
Thanks for responding. I’m just placing placing the JS in a file in the assets folder and letting it run.
When I place those files in a standard HTML document and let them run, they both work fine.
When I do the same with Dash, only the alert works.
Emil
September 17, 2020, 3:32pm
5
I think that’s because the Dash components are generated dynamically, i.e. the JS is actually run before the elements are loaded. I guess it would work, if you use the solution i posted here,
python, plotly-dash
to ensure that the JS is loaded after the components are loaded.
Thanks - will take a look!