How can I dispatch a livewire event from a table?
The table function is static, thus I cant call
$this->dispatch('something')
.14 Replies
The table method is a set up method. Where are you trying to call the dispatch?
A dispatch needs an action. Just calling the table method isn’t going to dispatch anything.
hello
Using $this when not in object context
Which makes sense, but i dont know how else to do itYou can access livewire in the closure and use it to dispatch with. Component $component and then $component->dispatch
Got it
I needed to access a method and found that component->getContainer()->getLivewire() actually is a thing 🙂
The dependency is filament livewire not livewire I believe
I learned from a YouTube if ever in doubt you can dd(get_defined_vars())
yeah. Filament has livewire as a dependency, since its built on top of it
wow this is cool
I always use dd() anyways, but I wasnt aware of this
Here’s the docs mentioning the injected classes
yess
Wrong link sorry this is the one https://filamentphp.com/docs/3.x/actions/advanced
Seems it actually was the regular livewire class 😂 I didn’t even look I just used the dep injection in vscode to import the class
Yeah, I literally just remembered it existed.
Your thoughts are always clearer after a gooood 10h sleep 😂
I’m curious did that work for you?
Also you can use ->to() with dispatch to define which component will receive the event.