Is there a way to hook an alpine event when a table loads new results?

I need to hook an alpine event whenever a table loads new results. Is there a way I can do this?
Solution:
The Livewire hooks are documented in their docs: https://livewire.laravel.com/docs/javascript#javascript-hooks...
Laravel
JavaScript | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Jump to solution
5 Replies
Dennis Koch
Dennis Koch7mo ago
Should be the default Livewire JS event
deadbeef
deadbeefOP7mo ago
Sorry, I’m new to the livewire space - prior all Vue/API work. How do I find the name of that event?
Dan Harrin
Dan Harrin7mo ago
Maybe using a Livewire “commit” hook - what are you trying to achieve?
Solution
Dennis Koch
Dennis Koch7mo ago
The Livewire hooks are documented in their docs: https://livewire.laravel.com/docs/javascript#javascript-hooks
Laravel
JavaScript | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
deadbeef
deadbeefOP7mo ago
Thank you guys! I’ll give this a try shortly Got it, feels a bit hackish but it works. Thank you guys!
Livewire.hook('commit', ({ component, commit, respond, succeed, fail }) => {
// Runs immediately before a commit's payload is sent to the server...

respond(() => {
// Runs after a response is received but before it's processed...
})

succeed(({ snapshot, effect }) => {
if(snapshot.includes('\"actionSubmitText\":\"Submit\"')) { // adjust snapshot check to your needs
// do whatever you need here
}
})

fail(() => {
// Runs if some part of the request failed...
})
})
Livewire.hook('commit', ({ component, commit, respond, succeed, fail }) => {
// Runs immediately before a commit's payload is sent to the server...

respond(() => {
// Runs after a response is received but before it's processed...
})

succeed(({ snapshot, effect }) => {
if(snapshot.includes('\"actionSubmitText\":\"Submit\"')) { // adjust snapshot check to your needs
// do whatever you need here
}
})

fail(() => {
// Runs if some part of the request failed...
})
})
Want results from more Discord servers?
Add your server