I’m using Laravel with TailwindCSS, so I assume that, the SweetAlert wouldn’t work.
I’m also using Livewire Powergrid, which works fine, but I don’t know how to emit simple alert window after clicking f.e. "Delete" button.
Inside actions
method, there’s option emit()
but I really don’t know what it does.
Button::make('destroy', 'Delete')
->class('bg-red-500 cursor-pointer text-white px-3 m-1 rounded text-sm hover:bg-red-800')
->emit(),
What does it call and where? Should I put emited
method inside UsersTable
(powergrid component) or somewhere else?
Can someone explain? There’s other possibility to achieve the alert
window with confirmation?
2
Answers
You have to pass the method name within
emit
and that method has to be defined in the same class (I am using PowerGrid Component), example :In the same class, define the method also
In the frontend (blade file or the view file) define the
showAlert
javascript.In my case , I had to add both the event and the listener to the mother component , instead of the PowerGrid class (cause it was not working )
Inside Powergrid class (UserTable) , I have these buttons inside actions function
Livewire Mother Component
Livewire Mother Component Blade
sample image 1
I used Livewire Alert package