We need to bring this topic back up, as the NodeJS SPA Load action isn’t working at all, and the workaround suggested by @patrick doesn’t work in our case either.
We have a query parameter intended to scroll the page to a section whose id is passed via the URL query:
The problem is that when this flow executes, the DOM doesn’t seem to be fully loaded, causing the scroll to jump to an incorrect location. However, if I trigger this flow manually (e.g., on a mouse click) after the page has fully loaded, it scrolls to the correct element.
I’ve also tried triggering the flow on page load with: dmx-on:ready="flow1.run()" - but that doesn’t work at all.
It has just been something that is so very needed when developing a spa and I have been forced to find workarounds like putting a wait step on my page flows or running the flows when a animated region displays(making sure it is put at the top of the page). All of these are hacks applied because of app connect not being able to observe app level load and ready dynamic actions on content pages.
Other option is to try and conditionally add the flow on the layout page and maybe run based on route. Again a workaround for something that seems easy to fix for the Wappler devs when they are done with all the AI development.
These events were never available for content pages, they have always been only available for the main/layout pages. Content pages don't have events.
If you want to run anything on page load you can add a flow on the content page and set its action to auto run.
Can you share your whole code then? If there is no repeat or any dynamic data needed for the sections to be shown/rendered on the page, there should not be any need for delay step to be used.
Is the sections content dynamic? It is possible that the scroll runs before the dynamic content is loaded, so the section(s) don’t yet have their actual height and the browser is scrolling to a wrong location.
Yes when you add the code you pasted the browser height becomes more than 100% and probably then it just scrolls to the correct position. When your content is less than 100% of the browser height (when your content is not yet loaded), there is just not enough space to scroll down.