I have two a view that loads a livewire component
<x-layouts.formularies>
<livewire:formularies.edit.display-section :section="$section->id" :formulary="$formulary->id" />
</x-layouts.formularies>
This component (display-section) calls a child component in a loop...
<div class="letter mx-auto" id="section-holder">
<div class="paper-title d-flex justify-content-between">
@foreach($questionnaire->getData( 'logos', [] ) as $logo)
<img src="{{ asset($logo[ 'path' ]) }}" class="img-fluid h-100" />
@endforeach
</div>
<div class="section-questions">
@foreach($section->questions as $question)
<livewire:formularies.edit.display-row :question="$question->id"
:formulary="$formulary->id" :wire:key="$question->id" />
<hr />
@endforeach
</div>
</div>
Now, this is the display-row component:
<div class="card-body text-center p-1">
<div class="btn-group m-1" role="group" aria-label="question-{{ $question->id }}">
@foreach($question->answers as $answer)
<input type="radio"
wire:model="answer"
:wire:key="$question->id . '-' . $answer->id"
wire:click="setAnswer"
class="btn-check"
value="{{ $answer->id }}"
name="question-{{ $question->id }}"
id="question-{{ $question->id }}-{{ $answer->id }}"
autocomplete="off" />
<label class="btn btn-outline-teal text-dark mb-0"
for="question-{{ $question->id }}-{{ $answer->id }}">{{ $answer->statement }}</label>
@endforeach
</div>
</div>
When the user picks an option from the radio button, it does some database stuff and fires an event that should be listened by the parent component (display-section):
public function setAnswer()
{
$this->emit( 'formularyUpdated', $this->formulary->id );
FormularyUpdated::dispatch( $this->formulary, $this->question, $this->answer );
dd( 'I should not get here if there is a dd before' );
}
As you can see, this function emits a formularyUpdated event with the id of the formulary. And in the DisplaySection I have this:
protected $listeners = [
'sectionAdvanced',
'formularyUpdated',
];
/**
*
*/
public function formularyUpdated( Formulary $formulary )
{
dd( 'This dd should stop the execution' );
}
For some reason, this always ends with "I should not get here if there is a dd before" so, what should I change? why is my listener not listening or not being fired? I have tried different approaches without luck.



