Go to top with pagination

Hello,

I seen other posts about how to perform a go to top in pagination but I’m unable to achieve it.

In a component, where I render a list and his pagination links. Everything works well but I can’t fire the event to make a scrollTop.

In a list component, I have the foreach followed by {{ $items->links(‘livewire.search-pagination’) }}

Then in pagination view, I call next page by wire:click=“gotoPage({{ $page }})”

I tried emit, overriede goToPage function, … but I didn’t arrive to do this simple thing.

Could you help me ?

Thanks !

Okay guys, too many months with Inertia and I loose the basics of js and blade …

The solution was quite simple :
1/ Override gotoPage function
public function gotoPage($page)
{
$this->setPage($page);
$this->emit(‘gotoTop’);
}

2/ Add js thanks in @stack(‘scripts’) and @push(‘scripts’)

Here the thing, Livewire must be used after page load …

Thanks anyway for all the answers in the forum !!

Hey, @arnaud

You can take a look here: