Endless scrolling through Drupal pages, skipping the second page

I have a Drupal site, on the main page all the site content is presented. It is paginated, and I use jQuery plugins for Freemasonry and infinite scrolling.

The first page loads fine, and when you scroll down, it works as it should. However, it actually slips right above the second page of content (page 2 in pager links). And I can’t understand why.

When the page first loads, if you DO NOT MISS, you can hover over the pagination and see the URL that each link points to. When I launch the site in firebug, AJAX actually loads what would be in the form of a page as the first page, and skips right above the page.

See page here http://ninja.oncommunication.ca/

Is it because Drupal starts at page 0 in this pagination? I think the Infinte Scroll plugin just reads the URL from the “next” link, but this is obviously not because this link points to page = 1 (which is the second page paginated), but when you scroll down , first page loaded - Page = 2 (which is the third page paginated)

Any help?

+4
source share
2 answers

I had similar problems before, try setting currentPage when initializing infinatescroll, for example:

note that all you need is currPage: 1 , but I have included the full set of parameters because I find that the parameters and subsets of more parameters tend to be confusing.

Try playing with this number, maybe 0 or 2 will work? Basically you tell infinateScroll which page you start on, because sometimes it cannot figure it out based on the following link.

  // initialize scroller $('.infinateScroll').find('ul:first').infinitescroll({ // setup scroller options navSelector : ".pager", nextSelector : ".pager > li.next > a", itemSelector : ".infinateScrollItem", debug : false, animate : false, loading: { finished: function() {}, finishedMsg: "<p>No More to Load!</p>", msg: null, msgText: "<p>Loading&hellip;</p>", selector: null, speed: 'fast', start: undefined }, state: { isDuringAjax: false, isInvalidPage: false, isDestroyed: false, isDone: false, // For when it goes all the way through the archive. isPaused: false, currPage: 1 }, bufferPx: 300 // ideal setting 300 } 
+1
source

Have you considered using View Infinite Scroll for the same?

0
source

Source: https://habr.com/ru/post/1439913/


All Articles