Paginator: react on page change clicks in JS

The problem: paginator is located at the bottom of the post comments. If the user clicks on paginator and selects a new page the screen is showing something unexpected for the user. Comments have different number of rows and after switching page user can be located in the middle of the comments or in the footer part of the page.

Is there a simple way to trigger on page change clicks in JavaScript? I want to add a scroll up function to the beginning of comment section.

haha, I was thinking “I am smart” and created my own paginator with the hope that reference #link will navigate user to the right place. So i created a code like

<a href="#{{$pageLink}}" class="page-link" wire:click="gotoPage({{$page}})">{{$page}}</a>

So what this code really does:
First click works. It navigates to the right page and change the browser url to {url}?page=x.
Next click does weird thing. Basically it changes browser url to url plus link like: {url}#link and the page got navigate there… So the real page after second click becomes 1…

Next possibility is to mess with JS… Will keep you updated :grinning: