Closed cyberkid042 closed 3 years ago
I've come across this and done some investigating.
The session('alert.config') gets passed to the Livewire component and can be used but it seems to get wiped after the component. That's why the sweet alert script isn't firing.
I haven't found the solution yet but it may not be a Sweet Alert problem.
Just found this https://github.com/livewire/livewire/issues/2294
I solve this (or I got around the problem), by emitting an event on the Livewire class, and now I use the javascript package of Sweet Alert. I created some scripts to listen this events and trigger the alert message. Works like a charm, showing alerts, opening modals, etc.
I have the same issue the Alert not displayed on pages with livewire components?
Hey you all.
Please checkout https://dev.to/realrashid/how-to-use-sweetalert2-with-livewire-56i6 this.
Detailed description
Example: When a store function is called on larval controller and it is successful, a return redirect is made withToastSuccess and normally, this works. But if the page I am redirecting to, has any livewire component, then sweet alert won't show on that page. So, the redirect is done, but no message is shown.
Context
With the growing use of livewire in laravel, this will continue to ensure a good user experience since users will continue to get a message back for a performed action.
Possible implementation
N/A
Your environment