Wappler Version : 5.8.2 beta channel
Operating System : mac
Server Model: node
Database Type:
Hosting Type:
Expected behavior
The dynamic on success event should not run when navigating away from a content page
Actual behavior
The event is triggered and generates this error, because the element referenced is no longer in the DOM

How to reproduce
Page1 has an SC with dmx-on:success that runs an inline flow. As part of this flow, a javascript function is run (loadSortableIngredients). Page1 works properly.
However when navigating away to any other page, the loadSortableIngredients function is errantly run. The each_recipe_ingredient
element is no longer in the DOM, and errors.
So if I understand correctly, you navigate away while the serverconnect is loading and it then throws an error when it finished the loading since it was already removed.
Not exactly.
I navigate to Page1 and the SC runs and triggers the dynamic on success event. This triggers an inline flow that runs the js function. All good to here.
I then navigate to another page, which works fine, but the error is thrown showing that the js function that previously ran, runs again.
I think what is happening is that because the SC has an input parameter with an expression of query.recipe_id
, the removal of the query parameter (because the url changed) is triggering the SC to run again.
And Yes, I could add dynamic auto load, however just noting this is a change from AC1, probably because everything happens faster!
Actually, let’s close this one. I can’t replicate it this morning either.
Nevermind, it is still erring, I had a filter on the dev console errors.
I think it indeed happens due to App Connect 2 reacting faster, changes are directly triggering reactions. So the serverconnect directly detects the change of the query parameter and reloads and then you get a racing condition with the view. I don’t know what kind of action you do after the serverconnect is loaded, but perhaps you could debounce the event.
The only other solution I can think of is that I change the view component, the view now replaces it contents after is successful loaded the new fragment, perhaps it should remove the old content directly on navigating and then show the new content when it is loaded. The only problem is that you have a blank page for a moment while it is loading and it will not show anything if there was an error loading the page.
I would vote for leaving view as it is.
It will be interesting to see if other bug reports come in that ultimately will force a change of user code as a result of the improved speed. I can already see changes I’ll be making.