Level 50
It seems you do not install livewire. May be you do not include assets
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi Guys. I have a quiz page that was working last year and out of nowhere I get "Uncaught ReferenceError: $wire is not defined at [Alpine] secondsLeft = 120; $wire.changeQuestion()" when completing a quiz. Here's my code:
<div
x-data="{ secondsLeft: {{ config('quiz.secondsPerQuestion') }} }"
x-init="setInterval(() => { if (secondsLeft > 1) { secondsLeft--; } else { secondsLeft = {{ config('quiz.secondsPerQuestion') }}; $wire.changeQuestion(); } }, 1000);">
<div class="mb-2">
Time left for this question: <span x-text="secondsLeft" class="font-bold"></span> sec.
</div>
<span class="text-bold">Question {{ $currentQuestionIndex + 1 }} of {{ $this->questionsCount }}:</span>
<h2 class="mb-4 text-2xl">{{ $currentQuestion->question_text }}</h2>
@if ($currentQuestion->code_snippet)
<pre class="mb-4 border-2 border-solid bg-gray-50 p-2">{{ $currentQuestion->code_snippet }}</pre>
@endif
@foreach($currentQuestion->questionOptions as $option)
<div>
<label for="option.{{ $option->id }}">
<input type="radio"
id="option.{{ $option->id }}"
wire:model="questionsAnswers.{{ $currentQuestionIndex }}"
name="questionsAnswers.{{ $currentQuestionIndex }}"
value="{{ $option->id }}">
{{ $option->option }}
</label>
</div>
@endforeach
@if ($currentQuestionIndex < $this->questionsCount - 1)
<div class="mt-4">
<x-secondary-button x-on:click="secondsLeft = {{ config('quiz.secondsPerQuestion') }}; $wire.changeQuestion();">
Next question
</x-secondary-button>
</div>
@else
<div class="mt-4">
<x-primary-button wire:click="submit">Submit</x-primary-button>
</div>
@endif
</div>
It appears the Laravel Notify package and Livewire don't work well together. I disabled removed notify and the quiz submission works now.
Please or to participate in this conversation.