Alert before button click
<button type="button" wire:click="remove({{ $user->id }})" onclick="return confirm('Are you sure you want to remove this?');" >
Remove User
</button>
Alert before button click
<button type="button" wire:click="remove({{ $user->id }})" onclick="return confirm('Are you sure you want to remove this?');" >
Remove User
</button>
2
Answers
and move the wire:click after. It won’t get hit if the confirmation is cancelled.
onclick="confirm('Are you sure you want to remove this?') || event.stopImmediatePropagation()"
You can use Livewire’s wire:click event in combination with JavaScript for confirmation