Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Livewire Confirm Before Action

Add confirmation dialogs before destructive actions.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Simple Confirm
  2. With Alpine
  3. Custom Modal

Confirm before actions:

Simple Confirm

blade
<button wire:click="delete" wire:confirm="Are you sure?">
    Delete
</button>

With Alpine

blade
<button x-on:click="if(confirm('Delete?')) $wire.delete()">
    Delete
</button>

Custom Modal

blade
<div x-data="{ open: false, id: null }">
    <button @click="open = true; id = {{ $item->id }}">Delete</button>
    
    <div x-show="open" class="modal">
        <p>Are you sure?</p>
        <button @click="$wire.delete(id); open = false">Yes</button>
        <button @click="open = false">No</button>
    </div>
</div>
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read