I’ve got a very simple use case that it’s becoming more complex than what I expected.
Basically I have to bind a select (html) change event to my pyscript script. However, for UX, I want to show a loader once select change event is triggered and remove it once it is all done. Well, that’s becoming quite of a challenge.
what I’ve tried so far;
-
Pure pyscript → I’ve creted my html loader (hidden) and tried to access it in pyscript (through js document) and update its className and upate it accordingly to my css style for the loader. Basically using display=“block/none”. Nothing happened (still not sure why)
-
js + pyscript → I’ve created my logic in js, so that the select onchange event would show the loader and I register a timeout to check every second if a specific div (the one with conent) has new content. This somehow works, but not as expected. It seems pyscript triggers first the change event, so all the computation is done, after the computation, the loader appears, just straight after, the new data is rendered and the timeout removes the loader. Therefore, UX-wise, it is still insufficient…
I am wondering if I am overcomplicating, or if there is any resource to understand better the event lifecycle between javascript/pyscript.
Thanks in advance!