Apr 11, 2024
0
Level 1
Dispatching Data from Javascript to LW component
My goal is to dispatch an array from a script - into a livewire component. I have a select2 im working with wire:model is not playing nice.
If I dd($values) inside the component - that works and I can see the data. But if I try to remove the dd() and do something else with the variable. I get this error.
Unable to resolve dependency [Parameter #0 [ <required> $values]] in class App\Livewire\Foo
script.js
document.addEventListener('save', (event)=>{
Livewire.dispatch('save',{values:"testing"});
})
livewire component
class Foo extends Component
{
protected $listeners = ['save'];
public function save($values)
{
dd($value);
return false;
}
}
Please or to participate in this conversation.