why not dispatch the event at the end of your livewire method and listen for it in javascript?
Aug 18, 2023
4
Level 15
Livewire: run JS on page update
Hello everyone,
Every time Livewire updates the page (after a server request), I want to execute some JavaScript.
I can't however figure out which hook to use.
I tried using the function $this->js(), but that function calls the javascript before the page gets updated. I need to run the javascript code after the dom updates are done.
I also can't use the Livewire.hook('request', ...) method for the same problem as $this->js().
Thank you in advance!
Level 15
Thanks for your answer, but that doesn't quite work.
I found the answer: wrap the function in a timeout call, so: $this->js('setTimeout(renderMath)');
Please or to participate in this conversation.