Confirm Livewire Action through Alpine JS Dialog
Example Alpine JS Livewire
Demo
This is a free component. Login to your account to view / download the component code.
Component Class
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class ConfirmEventCapture extends Component
{
public $count = 0;
public function render()
{
return view('livewire.confirm-event-capture');
}
public function increment()
{
$this->count++;
}
}
Component View File
<div>
<div x-data={}>
<h1 x-text="$wire.count"></h1>
<button class="btn btn-primary text-white"
x-on:click="if (confirm('Confirm Icrement?')) {
$wire.increment()
}">
Push Me to Icerement
</button>
</div>
</div>