Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:06:45+00:00 2026-06-08T08:06:45+00:00

I’m having a bit of trouble with Paul Irish’s infinite scroll plugin. If I

  • 0

I’m having a bit of trouble with Paul Irish’s infinite scroll plugin. If I only have 1 page of results, it works perfectly fine, but if I have more than one page of results it repeats the last page over and over again. Here is my infinite scroll configuration:

$('#grid').infinitescroll({
navSelector  : "#paginationControl:first",
nextSelector : "#paginationControl a#next:first",
itemSelector : "#grid .entry",
debug : true,
bufferPx : 500
},
function(newElements){
//Apply masonry
var $newElems = $( newElements );
$newElems.imagesLoaded( function(){
    $("#grid").masonry( 'appended', $newElems );
});
    //See if this is the last page
if( curPage >= pages ){
    alert("Infinite scroll is paused.");
    $('#grid').infinitescroll('pause');
}
});

And here are my pagination controls:

<?php if ($this->pageCount): ?>
<div class="paginationControl" id="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
    <a href="<?php echo $this->url(array('page' => $this->previous)); ?>" id="previous">
        &lt; Previous
    </a> |
<?php else: ?>
    <span class="disabled">&lt; Previous</span> |
<?php endif; ?>

<!-- Numbered page links -->
<div id="numberedPages">
<?php foreach ($this->pagesInRange as $page): ?>
    <?php if ($page != $this->current): ?>
        <a href="<?php echo $this->url(array('page' => $page)); ?>">
        <?php echo $page; ?>
        </a> |
    <?php else: ?>
        <?php echo $page; ?> |
    <?php endif; ?>
<?php endforeach; ?>
</div>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
    <a id="next" href="<?php echo $this->url(array('page' => $this->next)); ?>" >
    Next &gt;
    </a>
<?php else: ?>
    <span id="next" class="disabled">Next &gt;</span>
<?php endif; ?>
</div>
<?php endif; ?>

I figured that since the next page selector on the last page is disabled it would stop when it hit the last page. Why does it keep loading the last page over and over again and how can I stop it from happening?

EDIT:

I added an if check to the callback function to try to stop the scroll after a while, inspired by this question jQuery InfiniteScroll plugin loads the last page over and over.

//See if this is the last page
if( curPage >= pages ){
    alert("Infinite scroll is paused.");
    $('#grid').infinitescroll('pause');
}

Where pages is defined as the last page available and curPage is the current page, incremented each call. The check was working perfectly at one point, but I changed something, I’m not sure what, and now for some reason now I’m getting the error $("#grid").infinitescroll is not a function
$('#grid').infinitescroll('pause');
I have no idea how infinite scroll is not a function at that point when it clearly had to be for javascript to get to it in the first place. How can I get rid of this not a function error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:06:46+00:00Added an answer on June 8, 2026 at 8:06 am

    If you give zend’s paginator a page number that doesn’t exist, it simply retrieves the closest valid page number. If there were 20 valid pages and I tried to retrieve the 400th, it would simply return the 20th. I added code to the backend to throw 404s and it stops on time now. The infinite scroll script simply keeps loading pages until the backend throws an error so it didn’t know it was repeating itself.

    if($page_num > $pager->getPages()->pageCount){
            $this->_response->clearBody();
            $this->_response->clearHeaders();
            $this->_response->setHttpResponseCode(404);
        } 
    

    I would guess that the disabled next page selector in my pagination controls didn’t stop the infinite scroll script from selecting the next page because it only uses the controls to figure out the page url scheme and then simply increments the numbers from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.