Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda