Hey all, Can we start the loader or loading functi...
# suitescript
h
Hey all, Can we start the loader or loading function on-field change trigger?
w
Perhaps moving the code that you have in the pageinit entry point to separate functions and then call those functions from the fieldchange entrypoint. Or just call the pageinit from the fieldchange.
h
I have a button with a user event script and attached a client script to that form. Then On click of the button, I want to perform some task. And I want to show a loading spinner during task execution. But Loading spinner shows up after the task is done.
w
in the beginning of the execution create some form of loading popup and then when the function is complete, remove said loading popup.
h
That's what I did, but because of the single-threaded nature of javascript, the js engine prefers the code execution over UI updating. That's why UI is not updated until the js code is executed completely.
b
what does the code look like
w
But if the first thing you do is to create and display the loader-thingy, how could the other execution go before?
as @battk said...
h
@Watz, @battk I did exactly what you are saying. But I have found the issue. JS is single-threaded. It can only do one thing at a time either update UI or execute js code. And the js engine prioritizes code execution over UI. That's why, in code, the
showLoadingSpinner
logic is executed perfectly but we can't see the changes in the UI because the thread is busy executing the rest of the js code. I have fixed this issue using
setTimeout
because this function is async in nature.
w
no code shown then 🙂
h
@Watz Code Snippet With Spinner Issue
Issue Resolved with setTimeOut