Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger last page hit if loaded page appends 0 items #840

Closed
desandro opened this issue Oct 29, 2018 · 6 comments
Closed

Trigger last page hit if loaded page appends 0 items #840

desandro opened this issue Oct 29, 2018 · 6 comments

Comments

@desandro
Copy link
Member

A couple issues like #761 and #839 have popped up where a page loads but returns 0 items. At this point Infinite Scroll will then try to load the next page, which could trigger a loop of endlessly loading pages. One solution is to add a conditional where, if append is enabled, and the loaded page includes 0 items, then that be considered the last page hit.

Add a 👍 reaction to this issue if you would like to see this feature added. Do not add +1 comments — They will be deleted.

@marsccyu
Copy link

marsccyu commented Nov 9, 2018

I got this problem...returns 0 items and trigger a loop of endlessly loading pages
how can I interrupt loendlessly loading in this version?

@zieru
Copy link

zieru commented Dec 19, 2018

+1 using json keep loaded after last record, and pageindex is incrementing.

@iSk2y
Copy link

iSk2y commented Mar 22, 2019

I also met this problem, but I found that the page I wanted to load contained page-link class , like this

<ul class="pagination justify-content-center flex-wrap">
<li class="page-item active"><a href="?index-1.htm" class="page-link">1</a></li>
<li class="page-item"><a href="?index-2.htm" class="page-link">2</a></li>
<li class="page-item"><a href="?index-2.htm" class="page-link"></a></li>
</ul>

Even on the last page it doesn't have much more content , the page also had this page-link class . like this

<ul class="pagination justify-content-center flex-wrap">
<li class="page-item"><a href="?index-1.htm" class="page-link"></a></li>
<li class="page-item"><a href="?index-1.htm" class="page-link">1</a></li>
<li class="page-item active"><a href="?index-2.htm" class="page-link">2</a></li>
</ul>

So I guess maybe use two classes selectors .page-item active could represent the last page .

$('.threadlist').infiniteScroll({
        path: '?index-{{#}}.html',
        append: '.thread',
        status: '.scroller-status',
        hideNav: '.pagination',
        debug: true,
        checkLastPage: ".page-item active",
        // responseType: 'document'
    });

Yes it workd!

@egallup02360
Copy link

This is still an issue with loading data via json. Loading data via json is really not documented very well. I hacked together a solution that stops the loading, but it doesn't trigger the .infinite-scroll-last message.

Also, is there a place that a commercial license holder can get support with this product?

@idmahbub
Copy link

idmahbub commented Nov 23, 2020

This is still an issue with loading data via json. Loading data via json is really not documented very well. I hacked together a solution that stops the loading, but it doesn't trigger the .infinite-scroll-last message.

Also, is there a place that a commercial license holder can get support with this product?

tray like this :
`
var container = $('.search-result').infiniteScroll({

path: '.pagination__next',

responseType: 'text',

history: false,

debug: false,

});

$container.on( 'load.infiniteScroll', function( event, response ) {

var data = JSON.parse( response );

parseItem(data);

return data.result.next_page_url ? console.log('Load') : container.infiniteScroll('destroy');

});
`

desandro added a commit that referenced this issue Jan 1, 2021
✅ fix checkLastPage with falsey function
@desandro
Copy link
Member Author

Infinite Scroll v4 has been released. Infinite Scroll includes revised behavior that the last page will be triggered if append is set, and there are no items to append. I'm closing this issue as resolved. Please open a separate issue if you encounter a problem with this new behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants