Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
JQuery/Bootpag pagination not returning next page to top of results

I have implemented JQuery/Bootpeg pagination on my website. It works beautifully except for one thing: when you click to move to a new page the new set of results is loaded, but the page remains at the bottom the new set of results where the pagination buttons are. This means the viistor has to scroll back up to the top of the page to scroll down through the new results, which I think is kind of clunky (I am showing 20 results per page).

Here are the HTML and JS coding I am using. I also have a PHP script which extracts the data from my database and displays it (fetchpages.php). Is there any way that the code can be tweaked so that the page redisplays from the top of the new results (either the top of the page or an anchor point on the page)?

$(document).ready(function() {
    $("#results").load("fetchpages.php");  //initial page number to load
    $(".pagination").bootpag({
       total: <?php echo $pages; ?>,
       page: 1,
       maxVisible: 5 
    }).on("page", function(e, num){
        e.preventDefault();
        $("#results").prepend('<div class="loading-indication"><img src="img/ajax-loader.gif" /> Loading...</div>');
        $("#results").load("fetchpages.php", {'page':num});
    });

});
<script type="text/javascript" src="scripts/jquery-1.11.0.js"></script>
<script type="text/javascript" src="scripts/jquery.bootpag.min.js"></script>
<div id="results"></div>
<div class="pagination"></div>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

JQuery:

$(window).scrollTop(0); // use this to set page back to top

$(document).ready(function() {
    $("#results").load("fetchpages.php");  //initial page number to load
    $(".pagination").bootpag({
       total: <?php echo $pages; ?>,
       page: 1,
       maxVisible: 5 
    }).on("page", function(e, num){
        e.preventDefault();
        $("#results").prepend('<div class="loading-indication"><img src="img/ajax-loader.gif" /> Loading...</div>');
        $("#results").load("fetchpages.php", {'page':num});

        $(window).scrollTop(0); // use this to set page back to top
    });

});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda