I thought it was possible to emit an event from livewire and be able to listen for said event on non-livewire alpinejs “components”.
Is this possible?
If so, can anyone point me toward the docs or an example?
Thanks.
I thought it was possible to emit an event from livewire and be able to listen for said event on non-livewire alpinejs “components”.
Is this possible?
If so, can anyone point me toward the docs or an example?
Thanks.
I have the same problem. Anyone can help?
Sorry…should have posted that I found a solution some time back.
From livewire component:
$this->dispatchBrowserEvent('custom-event-name', [
'key' => 'value',
]);
Your AlpineJS component:
<div x-data='{ whatever: true }'
@custom-event-name.window="doSomething(event)"
>
...
There may be different/better ways to do this, but this is what I found to work. If you find something different/better, please share.