flaviusmatis / simplePagination.js

A simple jQuery pagination plugin.
Other
784 stars 402 forks source link

page don't scroll on top while going next page.. #152

Open Farshan opened 4 years ago

Farshan commented 4 years ago

I have some products in my page, when I am clicking on next page, webpage is not scrolling on top. It just goes half the webpage. please help me out. thank you.

Sandy-Garrido commented 4 years ago

Hi - This issue isn't related to the script, however, to enable this on click. You'll need to declare a function in the onPageClick option. See Available Options for onPageClick

For example

$('#selector').pagination({
    items: numOfItems,
    itemsOnPage: postsPerPage,
    currentPage: currentPageNum,
    displayedPages: 4,
    onPageClick: function () { // <------  you can add a function to onPageClick
        window.scrollTo({top: 0, behavior: "smooth"}); // this is the line which will execute on page click.
    },
});