do you mean Livewire forum ? You have problems posting a new topic?
Livewire with SweetAlert2
Hi, Has anyone got this working? I want to use Livewire but hate the fact that the forum seems not open for ALL. Or may be i could't find a way to post my issue at least... anyways coming back to the topic. I am using https://github.com/realrashid/sweet-alert package in my project now after implementing Livewire its a shame that i can't use it as easily as i though. or is there something that i am missing??? Please advice!
I've not experienced any issues accessing the Livewire forum. Sorry can't really suggest anything.
To answer your question, not sure if this is the best way but works for me.
After installing Sweetalert in your view, add an event listener;
window.addEventListener('swal',function(e){
Swal.fire(e.detail);
});
The listener is looking for 'swal' events and within the event, passed the parameters to use with swal.
Then in Livewire component, after for instance, saving a record, fire the event;
$this->dispatchBrowserEvent('swal', ['title' => 'hello from Livewire']);
Note that this is not using any element of realrashid wrapper.
More parameters can be passed according to the sweetalert2 docs.
eg
$this->dispatchBrowserEvent('swal', [
'title' => 'Feedback Saved',
'timer'=>3000,
'icon'=>'success',
'toast'=>true,
'position'=>'top-right'
]);
Please or to participate in this conversation.