Hello everyone,
I have an event that happens periodically on a screen using Javascript setTimeout, and I want to spin an icon for a second every time it happens. If the event had a server action in it it would spin the icon for the duration of the action, and it does, but there is no server request, one local thing gets assigned to another local thing, so it's instantaneous and the usual IsLoading= True-Action-IsLoading=false trick does not do anything.
So I tried having a timeout in Javascript hoping the action being not instantaneous would make the page show the spinning icon, but it didn't help. Is there any way to manually display a spinning icon for a set duration of time?
Like I thought, just having a dummy action triggers the re-rendering of the screen for just long enough that you know something changed. It seems to me that the page is re-rendered on hitting server actions and the "End" nodes, and not in between.
Hi Mehmet,
Do you have the handler for that event defined?
If so, you should create the logic for the spinner there. Not sure if I'm understanding the issue.
Regards,
PZ
Hello Paulo,
What I'm doing is, I have an IsLoading variable that's usually false, and have an If on the screen that displays a spinner when IsLoading is True, and shows the page content when IsLoading is False.
When I set IsLoading to True, run a server action like refresh data, and set IsLoading back to false, the user sees a spinning icon during the time between setting IsLoading to True and setting it back to False. It works without a hitch when I have a server action in there. But when I just set one local variable to another, no server actions, the spinner is not shown.
It seems the page does not get re-rendered unless a server action is triggered, as in the debugger the spinning icon isn't shown on the screen until hitting the Refresh action. So that makes me think I can have an empty server action to trigger re-rendering of the screen.
hi,
You can use something like below javascript to show and hide spin icon:
you need to display it before calling setTimeout and hide inside setTimeout event handler.
Yea this should work. Thanks for the idea.