NodeJS: Clear session storage variables on CONTENT PAGE load?

Hey guys,

From what I understand so far, in NodeJS there is no app.load or app.ready dynamic event for CONTENT pages... (I mean the UI options are there but they just don't do anything)

So, the only way to run a piece of code (for example Clear Session Storage Variables) is to add a page flow in my content page, set it to auto run and include in the page flow the code I need to run on page load.

(Probably there are other more complicated ways of doing it but for what I need to do this workaround does the job)

Am I correct or there is another better way?

Yes, there are no app load/ready events for content pages.
You can do this exactly this way, by using a flow set to auto run.

2 Likes

Edit: The relevant point being dmx-on:load

1 Like

Hey @Apple

Thanks buddy but I'm sorry I tried to understand how to handle my content's page from withing the layout page with the dmx-on:load suggestion you dropped...
If you please enlight me :slightly_smiling_face:

You call the Page Flow on that dmx-on:load, but maybe that's not needed at all and you found the Page Flow Auto Run to work :slight_smile:

dmx-on:load is called on layout page...

<div is="dmx-view" id="content" dmx-on:load="run([{runJS:{function:'pageLoaded',outputType:'text'}}])">
    <%- await include(content, locals); %>
</div>

inside the above example of yours, I should check which content page is loaded and then run the appropriate pageflow (the correct session variables)
Or I could check for that inside the pageflow...

I mean this layout page controls a few content pages... How should I know which one is open?
New to NodeJS and I'm driving slower than the speed limit...
:stuck_out_tongue_winking_eye:

(forget it if I'm annoying...)

Too complicated for me, sorry :laughing:

I guess only by checking the URL (window.location.href or something similar)

1 Like

For me also complicated...

I'm thinking of leaving it till I "grow-up" :grin:

Thanks for trying though! I always welcome new challenges