I'm using Laravel 12 and Livewire 3, and now i'm trying to use sweetalert2 in component file. These are what I already do :
- install sweetalert2 : npm install sweetalert2
- in resources\js\app.js : import Swal from "sweetalert2"; window.Swal = Swal;
- in blade file : `@script window.addEventListener('swal-alert',function(e){ Swal.fire(e.detail); }); @endscript`
- in component file when wire:click in the button executed :
$this->dispatch('swal-alert', [ 'type' => 'success', 'title' => 'Success!', 'text' => 'Operation completed successfully.' ]);
But sweetalert2 does not show up.
In the blade file, I also using :
<button wire:loading class="btn btn-info"> Loading... </button>
this button-info is show up, but sweetalert2 does not show up, is this conflict ?
Please help.. Thank you...