Listen on js the render events when a Select change.

Hi. I have a question about render events. It's posible to listen the event with js when a Select field change to refresh some js functions?
8 Replies
toeknee
toeknee2y ago
Checkout the livewire listeners: https://laravel-livewire.com/docs/2.x/events
Livewire
Events | Livewire
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
LeandroFerreira
->afterStateUpdated(function ($livewire) {
$livewire->dispatchBrowserEvent('event');
}),
->afterStateUpdated(function ($livewire) {
$livewire->dispatchBrowserEvent('event');
}),
jals65
jals65OP2y ago
And it's posible to listen it in a x-on to change the data of x-data?
toeknee
toeknee2y ago
May I ask what is your goal?
LeandroFerreira
What are you trying to do?
jals65
jals65OP2y ago
I have a div with x-data={status: getStatus()} And i need to rerun getStatus() function and assign the return value to status when the select value change
LeandroFerreira
yes, take a look: https://laravel-livewire.com/docs/2.x/events#browser
<div x-data="{ status: getStatus() }" @update-status.window="status = 'xxx'">
<div x-data="{ status: getStatus() }" @update-status.window="status = 'xxx'">
$livewire->dispatchBrowserEvent('update-status');
$livewire->dispatchBrowserEvent('update-status');
Livewire
Events | Livewire
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
jals65
jals65OP2y ago
Ok, thanks, that works. Thanks you two @toeknee_iom and @Leandro Ferreira
Want results from more Discord servers?
Add your server