Method PowerComponents\LivewirePowerGrid\Button::confirm does not exist. Laravel Livewire Powergrid Error

396 Views Asked by At

Method PowerComponents\LivewirePowerGrid\Button::confirm does not exist.

I using laravel powergrid table action buttons now i click delete delete button confirmation alert not working show this error

My Livewire Action code

public function actions(): array
    {
       return [
        Button::add('view')
        ->caption('Edit')
        ->target('_self')
        ->class('btn btn-primary')
        ->route('productedit', ['id' => 'id']),
    Button::make('delete', 'Delete')
    ->target('_self')
    ->class('btn btn-danger')
    ->confirm('Are you sure you want to delete this record?')
    ->emit('productdelete', ['id' => 'id'])
        ];
    }`

1

There are 1 best solutions below

1
Sammar malik On

In Livewire-Powergrid, the confirm method of javascript cannot be directly called like this. If you want to get confirmation on the click of delete button, you can dispatch an event on button click of powergrid & create a listener in JS. Then inside listener you may write simple javascript to generate a confirmation and proceed further actions against the response of confirmation.