The case here that I cannot switch to Laravel component to have the pagination through livewire component. I need to stay with Laravel controller
Jul 21, 2023
5
Level 5
Laravel Infinite Scroll using AJAX and livewire component
Hello, I have implemented a Laravel pagination according to the below way of implementation.
public function index(Request $request)
{
$posts = Post::paginate(10);
if ($request->ajax()) {
$view = view('data', compact('posts'))->render();
return response()->json(['html' => $view]);
}
return view('posts', compact('posts'));
}
Inside the data view I have a livewire component that after the first page, it is rendering fine as far as view but it doesn't work. I think this is happening due to the way that the new data is going to the view using render and json. Do you have any alternative way of implementation of this?
Thanks Theo!
Please or to participate in this conversation.