Livewire emitTo not working in Widgets

i had two table widget, and register this widgets into ViewShipmentManifest page. but when action is executed nothing happened on event
9 Replies
kevariable
kevariableOP2y ago
typical my action like this in PendingShipOrderWidget
LeandroFerreira
protected $listeners = ['some-event' => '$refresh'];

//or

protected $listeners = ['some-event' => 'myEvent'];
public function myEvent()
{
//
}
protected $listeners = ['some-event' => '$refresh'];

//or

protected $listeners = ['some-event' => 'myEvent'];
public function myEvent()
{
//
}
https://laravel-livewire.com/docs/2.x/actions#magic-actions https://laravel-livewire.com/docs/2.x/events#event-listeners
Livewire
Actions | Livewire
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Livewire
Events | Livewire
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
kevariable
kevariableOP2y ago
the problem is my event not invoked
bwurtz999
bwurtz99917mo ago
@kevariable were you ever able to figure this out? I am having the same issue
awcodes
awcodes17mo ago
If you’re using LW3 then emitTo was replaced with dispatchTo
bwurtz999
bwurtz99917mo ago
@awcodes thank you but I'm still on v2 of Filament and Livewire
awcodes
awcodes17mo ago
wasn't sure. sorry.
bwurtz999
bwurtz99917mo ago
I'm still having an issue with this. Any idea why this wouldn't be working? I'm trying to emit and event from one widget to another I can emit an event to the same widget without issue but I can't get anything to send to the other widget Ok this is strange and I don't know how/why it works but I found a solution. I had to use ->id('teamNameFilter') on the TextInput I was trying to listen to for updates, then I had to fire the emit event from JS on the widget page
<script>
var el = document.getElementById('teamNameFilter');
el.addEventListener('keyup', (event) => {
Livewire.emit('teamNameUpdated', el.value);
})
</script>
<script>
var el = document.getElementById('teamNameFilter');
el.addEventListener('keyup', (event) => {
Livewire.emit('teamNameUpdated', el.value);
})
</script>
and then I need these on both widgets
protected $listeners = ['teamNameUpdated'];

// ...

public function teamNameUpdated()
{

}
protected $listeners = ['teamNameUpdated'];

// ...

public function teamNameUpdated()
{

}
On the widget I am emitting the event from, teamNameUpdated is empty with no dependencies On the widget I am trying to send the event to, it looks like this:
public function teamNameUpdated($name)
{
dd($name);
}
public function teamNameUpdated($name)
{
dd($name);
}
I have no idea why this works, or why it doesn't work when trying to emit the event from PHP, but it works
kevariable
kevariableOP16mo ago
I register the widget in the resource then working well
Want results from more Discord servers?
Add your server