Calling some JS code upon a LiveView update?

It’s also possible to listen for "phx:update" events which are (at least to my knowledge) emitted when the DOM is done being patched.

I used it in some of my “experiments” with client side js libs (similarly to LiveView: How to trigger JS function? (Update chart.js on data change)) to create/destroy/recreate their objects when the DOM elements they were “bound” to got “morphdomed”.

4 Likes