Refresh table in livewire component

Hello everyone! Why is the table reloaded before the component field is changed using wire.model.live? I have a checkbox that changes the query builder (initial state false), but the query is only changed when the checkbox is clicked again, the past state is taken (if true now, false is taken).
3 Replies
Patrick Boivin
I get a feeling this could be related to Livewire request batching. Can you share a bit more context on how your checkbox and custom query are setup?
l33tneko
l33tnekoOP2y ago
Component
class Sportsmen extends Component implements HasTable, HasForms
{
use InteractsWithTable;
use InteractsWithForms;

public bool $deletedSportsmen = false;

public function table(Table $table): Table
{
return $table
->query(SportsmanQuery::make(active: !$this->deletedSportsmen)->execute())
->columns([/* Columns */])
}
}
class Sportsmen extends Component implements HasTable, HasForms
{
use InteractsWithTable;
use InteractsWithForms;

public bool $deletedSportsmen = false;

public function table(Table $table): Table
{
return $table
->query(SportsmanQuery::make(active: !$this->deletedSportsmen)->execute())
->columns([/* Columns */])
}
}
View
<label class="label cursor-pointer w-fit">
<span class="label-text">Deleted sportsmen</span>
<input class="checkbox ml-4" type="checkbox" wire:model.live="deletedSportsmen">
</label>
<label class="label cursor-pointer w-fit">
<span class="label-text">Deleted sportsmen</span>
<input class="checkbox ml-4" type="checkbox" wire:model.live="deletedSportsmen">
</label>
Cyrillus Dodi
Cyrillus Dodi16mo ago
do you find the solution?

Did you find this page helpful?