Replies: 3 comments
-
@enfJoao this seems to be a Blazor question rather than an Oqtane question. Both Static and Interactive render modes in Blazor use an abstraction layer to simulate a SPA experience... and the abstraction layer affects the behavior of JavaScript. There is plenty of documentation available online about Blazor and JavaScript, which I would encourage you to read. |
Beta Was this translation helpful? Give feedback.
-
@enfJoao We've been tracking this issue in the 2sxc project and identified a problem in Interactive mode that caused the same inline JavaScript to execute multiple times on subsequent visits to the same page or module. This issue has been addressed and the fix is planned for the next 2sxc release. Note that it’s expected for inline JavaScript to run once every time a 2sxc module is rendered. Each render appends the inline script to the page’s HTML and executes it. This behavior is by design, so developers should be aware that inline scripts will run repeatedly as users navigate around the SPA environment. For cleaner code and fewer unexpected side effects, we recommend placing JavaScript in external files rather than using inline scripts. Since Oqtane sites operate as single-page applications, any JavaScript should be written to handle multiple executions gracefully, as the state persists within the browser session until a full page reload occurs. |
Beta Was this translation helpful? Give feedback.
-
Unfortunatly I still have many older apps that depended on razor code directly injected on the inline javascripts. Guess it's time to refactor. |
Beta Was this translation helpful? Give feedback.
-
Hey. This is still probably related to the render modes discussion on discord, but I have a few issues I would like to clarify.
I have a 2sxc app added to a single page with this content:
In static render mode:
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?
In Interactive render mode:
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.
Beta Was this translation helpful? Give feedback.
All reactions