First off - I should say - this is taken from this issue conversation on github - particularly from fra000’s comment on November 14th, 2019
When building any sort of database-driven app, I’ll want to have a Javascript Confirmation before actually performing an action for things like deleting something, or modifying something which performs a significant change.
With Livewire, you call the PHP function easily with something like this
<button wire:click="delete_object">DELETE!</button>
But that will call the delete code right away, so rather than doing that, we want to have something that prompts the user to say “Are you sure?” or something along those lines.
And here is how -
<button onclick="confirm('Are you sure?') || event.stopImmediatePropagation()"
wire:click="delete_object">DELETE!</button>