Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Javascript in inline tags running multiple times in Oqtane - Blazor - 2sxc

$
0
0

I'm using the Oqtane CMS/Framework (with Blazor) with 2sxc apps.

I added this 2sxc app (made just for this test) to a single page with this content:

<div id="something">Something</div><script>    const thisVar = "abc";    document.querySelector("#something").style.display = "block";</script>

If I move away from this page I get "Uncaught TypeError: Cannot read properties of null (reading 'style')"So the script is executing again (in pages where the module does not exist), but the html content does not exist.

If I move away from this page and then access it again, I get: "Uncaught SyntaxError: Failed to execute 'appendChild' on 'Node': Identifier 'thisVar ' has already been declared".Does the module retain the script execution after moving away from the page?

I know the optimal way to implement javascript in these apps is with external files, but I need to migrate the current working apps into Oqtane and then refactor them to better standards (there is a lot of dynamic razor code in these scripts).

Any good and simple guides or recommendations available on this subject?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>