I’m encountering an issue with my Livewire component where a method call is not being triggered.
I have a Livewire component in my Laravel project that includes a button with a wire:click directive bound to a method called showEventDay(). However, when I click the button, the method does not seem to be called, even though I’ve verified that the Livewire component is properly initialized and the method is defined correctly.
My blade file
<div class="bg-white border-2 border-slate-200 rounded-b-lg p-4 w-full">
<div class="mt-0">
<div class="mx-auto">
<div class="bg-white w-full max-h-85 rounded-lg">
<div>
<button id="eventDayButton" wire:click="showEventDay(1)" onclick="console.log('Button clicked')" class="relative rounded px-5 py-2.5 overflow-hidden bg-green-500 relative hover:bg-gradient-to-r hover:from-green-500 hover:to-green-400 text-white hover:ring-2 hover:ring-offset-2 hover:ring-green-400 transition-all ease-out duration-300;" >
{{ __('Add new event day') }}
</button>
@livewire('admin.event-days.edit', ['event' => $event])
</div>
</div>
</div>
</div>
</div>
My Component:
namespace AppLivewireAdminEventDays;
use LivewireComponent;
class Edit extends Component
{
public $event;
public $visible = 0;
public function showEventDay($value)
{
$this->visible = $value;
}
public function render()
{
return view('livewire.admin.events.editEvent');
}
}
Environment Details:
Laravel version: 11.0.5
Livewire version: 3.4.8
Mohit Jalmi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.