Comments (5)
Hi @altendorfme, you have to call this.append
, from the nextHandler
(from the final then
call).
return this.append(Array.from(frag.childNodes))
// indicate that there is a next page to load
.then(() => hasNextPage);
});
See this code for how to do this:
https://codesandbox.io/s/github/webcreate/infinite-ajax-scroll/tree/master/examples/json?file=/index.js
Please let me know if this helps.
from infinite-ajax-scroll.
Hi @fieg ,
There are two Ajax calls, the first is to bring the next URL:
[
{
"nextId": 2109671,
"nextUri": "https://next.com/next-post/"
}
]
The second call ias would take the information from the URL (nextUri), bringing the content.
I fork code, maybe it's easier in: https://codesandbox.io/s/romantic-cdn-yqurq
from infinite-ajax-scroll.
This is not a common use pattern for IAS. Why does the next url need to come from a json call? If you could tell me a bit more about your use case I can help you better.
from infinite-ajax-scroll.
Hi, this API route (With ElasticSearch) returns smarter related results.
from infinite-ajax-scroll.
I think this should do the trick:
function nextHandler(pageIndex) {
return fetch("./static/post.json")
.then((response) => {
return response.json();
})
.then((data) => {
let hasNextPage = pageIndex + 1 < data.length;
let nextUrl = data[pageIndex].nextUri;
return this.load(nextUrl).then((data) => {
return this.append(data.items).then(() => {
return hasNextPage;
});
});
});
}
https://codesandbox.io/s/relaxed-feynman-ofl38?file=/index.js
from infinite-ajax-scroll.
Related Issues (20)
- Is there any way to make this work with dynamic content like pjax or htmx HOT 3
- Exclude the 'javascript:;' from the next url HOT 5
- Bind on load (DOMContentLoaded)
- Regularly and randomly failing resize test
- Accessibility and Keyboard Navigation HOT 9
- VueJS support/example
- Doesnt work if link includes Get request (?srch=value) HOT 2
- Running over CDN vs npm, and pagination question HOT 3
- Limit the number of items HOT 1
- Not able to reload after ajax content load. HOT 1
- After form POST or GET result pagination not working HOT 2
- Prevent the url from changing when scrolling or in other words, the url stays at the same address? HOT 1
- Element ".pager__prev" not found for "options.prev
- Use item selector with ::last
- Prevent to close HTML Tags in appendFn
- <video> not loading in firefox HOT 1
- Loading duplicate pages on refreshing or going back to page
- Using scrollcontainer creates Js error on unbind
- Unhandled Promise Rejection: TypeError: null is not an object (evaluating 't[o].sentinel.getBoundingClientRect') infinite-ajax-scroll.min.js:11:11548
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from infinite-ajax-scroll.