@jgaleano I am not sure but I think it is because you are paginating in render and when current user chnage paginate render again. How about doing paginate in mount method and give the data to public $allusers property?
Oct 20, 2022
9
Level 1
How to prevent Livewire pagination on wire:click?
I have a list of users that are paginated and shown on a page. Each user has a button that when click a short form is displayed. All of this works great on the first page but when I click on another page and click on the button the first pages gets rendered.
How to prevent the pagination when I click one of these buttons? Livewire component:
public $currentUser = null;
public function render()
{
$allusers = Client::where('active', '1')->orderBy('name')->paginate(12);
return view('livewire.user-management', [ 'allusers' => $allusers ]);
}
public function showUserForm($currentUser)
{
$this->$currentUser = $currentUser;
}
Livewire user-management blade file:
@foreach($allusers as $user)
<div>
{{$user->name}}
<button wire:click.prevent="showUserForm({{$user->id}})"> Form</button>
@if($currentUser == $user->id)
<form>....</form>
@endif
</div>
@endforeach
Please or to participate in this conversation.