I have a button on my blade that calls a select method, this method emitted an event but it is not arriving
Button blade:
<div class="ml-auto">
<button class="br-button secondary circle" type="button" aria-label="Selecionar" wire:click="selecionar({{ json_encode($user) }})">
<i class="fas fa-arrow-right"></i>
</button>
</div>
Method Select: which is inside the search component
public function selecionar($user)
{
$this->emit('userSel', $user);
$this->buscaNome = "";
$this->usuarios = [];
}
Method userSel: which is inside the create component
protected $listeners = ['userSel'];
public function userSel($user)
{
$this->state = $user;
}
I’ve already tried to issue directly from the blade.
2
Answers
Check the network tab. emit should create a 2nd request (Livewire2) and you can check whether the listener gets executed:
In your case the create component should be present on the page
Modify the
{{ json_encode($user) }}
of the functionto
'{{ json_encode($user) }}'