Home > Enterprise >  Livewire : Wire click event handler not working on 2nd page or higher datatables
Livewire : Wire click event handler not working on 2nd page or higher datatables

Time:01-13

I am trying to trigger a livewire function from a wire:click in a datatables array.

This system works fine but only for the first datatable page. Nothing is triggered in the 2nd page or higher.

Here is my code :

event.php :

public function showEvent($eventId)
{
 return redirect()->route('events.show', [$eventId]);
}

event.blade.php :

<table  id="event-table" wire:ignore>
    <thead>
      <tr>
        <th >
          Nom
        </th>
      </tr>
     </thead>
    <tbody>
 @foreach ($events as $event)
  <tr  wire:key="{{ $event->id }}">
      <td  data-label="Nom" wire:click="showEvent({{ $event->id }})">
  </tr>
 @endforeach
  </tbody>
 </table>

Any suggestion ? Thanks

CodePudding user response:

Why you use livewire for this sulotion.

if rediorect to any page:

use a tag to redirect,

if show partial view in current page:

return view in showEvent method.

CodePudding user response:

Try to remove wire:ignore and wire:key="{{ $event->id }}" I don't see any pagination btw

  •  Tags:  
  • Related