Event after table items are reordered

Hi guys, Is there any way to run code after the Table items are reordered using the reorderable() method? There are no Model events, since they are updated using the ->update() method. Thanks!
1 Reply
BloodDrunk
BloodDrunk5d ago
Bumping this as I also need to dispatch a livewire event after reordering. I really don't want to use model update event and check if specific property is updated to determine what event to send.
return $table
->reorderable('sort_order')
->reorderRecordsTriggerAction(fn (Action $action): Action =>
$action->after(function () use ($livewire): void {
$livewire->dispatch('audit-reordered');
})
)
->defaultSort('sort_order', 'asc')
return $table
->reorderable('sort_order')
->reorderRecordsTriggerAction(fn (Action $action): Action =>
$action->after(function () use ($livewire): void {
$livewire->dispatch('audit-reordered');
})
)
->defaultSort('sort_order', 'asc')
My code ain't doing shit Ok I got it.
public function reorderTable(array $order, int|string|null $draggedRecordKey = null): void
{
parent::reorderTable($order, $draggedRecordKey);

$this->dispatch('audit-reordered');
}
public function reorderTable(array $order, int|string|null $draggedRecordKey = null): void
{
parent::reorderTable($order, $draggedRecordKey);

$this->dispatch('audit-reordered');
}
You can override that public method on livewire component (such as relation manager, or list records...)

Did you find this page helpful?