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

404 request before last page check with prefill #690

Closed
einkoro opened this issue Jul 17, 2017 · 4 comments
Closed

404 request before last page check with prefill #690

einkoro opened this issue Jul 17, 2017 · 4 comments
Labels

Comments

@einkoro
Copy link

einkoro commented Jul 17, 2017

When you use the prefill option it will 404 trying to grab a page that doesn't exist before the last check fires. I encountered this working with WordPress & WooCommerce but have created a minimal test case linked below.

[InfiniteScroll] pageIndex. current page determined to be: 1 from next link
[InfiniteScroll] initialized. on products
[InfiniteScroll] prefill
[InfiniteScroll] request. URL: /shop/page/2/
XHR finished loading: GET "https://shopmmcurate.com.dev/shop/page/2/".
[InfiniteScroll] scrollThreshold
[InfiniteScroll] load. Products – Page 2 – Shop MMCurate. URL: /shop/page/2/
[InfiniteScroll] append. 2 items. URL: /shop/page/2/
[InfiniteScroll] prefill
[InfiniteScroll] request. URL: /shop/page/3/
[InfiniteScroll] last. URL: /shop/page/2/
GET https://shopmmcurate.com.dev/shop/page/3/ 404 ()
[InfiniteScroll] error. Error. URL: /shop/page/3/
XHR failed loading: GET "https://shopmmcurate.com.dev/shop/page/3/".
$( '.archive .products' ).infiniteScroll( {
    path: '.page-numbers .next',
    append: '.product',
    prefill: true,
    debug: true
} );

Test case: http://mmcurate.com/test/test-case.html

@desandro desandro added the bug label Jul 19, 2017
@desandro
Copy link
Member

Thank you for reporting this bug! This issue will be fixed in the next release of Infinite Scroll.

desandro added a commit that referenced this issue Aug 4, 2017
🛠 checkLastPage on append
✅ add test for prefilling on error

Ref #690
@desandro
Copy link
Member

desandro commented Aug 4, 2017

v3.0.1 has been released with this fix added. Please update! Closing this issue has resolved 🌈🐻

@desandro desandro closed this as completed Aug 4, 2017
@throwandgo
Copy link

The current implementation calls this.checkLastPage on append, as below:
this.on( 'append', this.checkLastPage );

Wouldn't it make more sense to call this.checkLastPage on load, especially since append is set to false by default?
this.on( 'load', this.checkLastPage );

@desandro
Copy link
Member

desandro commented Sep 8, 2017

@AustinBenavides Hmm, this is an interesting idea. I'll re-open this issue to consider it.

@desandro desandro reopened this Sep 8, 2017
desandro added a commit that referenced this issue Jan 12, 2018
ref #690

do not tie it to append
@desandro desandro closed this as completed Dec 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants