Methods

constructor

argument
type
description
container
string|Element
Selector or Element of the container (see definitions/concepts)
options
object
Configuration for this instance of Infinite Ajax Scroll (see options)
1
// import if you use the NPM package (not needed if you use CDN)
2
import InfiniteAjaxScroll from '@webcreate/infinite-ajax-scroll';
3
4
let ias = new InfiniteAjaxScroll('.container', {
5
item: '.item',
6
next: '.next',
7
pagination: '.pagination'
8
});
Copied!

bind

This will bind Infinite Ajax Scroll to the scroll and resize events of the scroll container.

unbind

This will unbind Infinite Ajax Scroll from the scroll and resize events of the scroll container.

next

This will load the next page manually.

load

This wil load an url and returns a promise which represents the loaded event.
argument
type
description
url
string
Url to load
If the request fails, the promise will be rejected with the XMLHttpRequest object.
1
ias.load('http://my-domain.test/page1.html')
2
.then((loadedEvent) => {
3
console.log('Requested ' + loadedEvent.url + ' successfully');
4
})
5
.catch((xhr) => {
6
console.log('Request failed with ' + xhr.status + ' (' + xhr.statusText + ')');
7
});
Copied!

append

Use this method to append an array of items to the container.
It will return a promise.
argument
type
description
items
array
Array of element to append to the container
parent
Element|null
Container to append to. When none given it falls back to the configured container

enableLoadOnScroll

Enables the loadOnScroll setting on runtime.

disableLoadOnScroll

Disables the loadOnScroll setting on runtime.
Last modified 1mo ago