Livewire 3 equivalent for Livewire 2 'livewire:update' hook
Hi all,
I'm upgrading my application from Livewire 2 to Livewire 3. If memory serves me right, the 'livewire:update' hook in Livewire 2 would fire after a network response and DOM manipulation is done. In Livewire 3, I see a couple of alternatives, but they aren't ideal.
'morph.updated' - This fires after the DOM is updated, but it fires after every DOM manipulation. Ideally I'd like to fire my hook only once per network request.
'request' > succeed - This fires once per network request, but it seems to fire before the DOM is updated.
Is there another, more appropriate hook? I'm resorting to 'morph.updated' because I have to fire my code after the DOM is updated, but I'm worried about the performance impact of firing it after every individual DOM update.
I don't see it described in v3 documentation, but element.updated javascript hook should still be available and might be helpful for you depending on your use-case.
@AdamVaclav Thanks Adam, that's a good thought, and it looks this existed in Livewire 2, but I'm not finding it in Livewire 3. I tried adding the hook, and it's not getting triggered.
@AdamVaclav It looks like livewire 3 has removed livewire:load as well. DOMContentLoaded and livewire:init do work though, but element.updated still doesn't work even when using DOMContentLoaded/livewire:init.
@Snapey I think that would work too. The way the code is currently designed, the listener is pretty generic for "listen for any DOM updates that introduce one of X classes that require special handling." Dispatching an event from the render method would require updating 10-20 places but I think it would work.