Option name | Type | Description |
---|---|---|
selector | string_or_domelement_or_jqueryobject | A selector string, DOM element, or jQuery object containing content that will be updated asynchronously |
paginationSelector | string_or_domelement_or_jqueryobject | A selector string, DOM element, or jQuery object containing the content pagination |
options | object | An object containing required options for this instance |
NATION.Utils
NATION.EventDispatcher
Loads content asynchronously and appends it to the bottom of the existing content.
Can work with the main browser scrollbar, but can also work within scrollable elements (with overflow:scroll).
Can load content based on scrolling, or on the press of a 'load more' button.
<!-- HTML -->
<section class="scrollable-content">
<div class="article-list">
<article>
<h1>Article 1</h1>
</article>
<article>
<h1>Article 2</h1>
</article>
<article>
<h1>Article 3</h1>
</article>
</div>
<ul class="pagination">
<li><a href="/?page=2" class="js-next">Next page</a></li>
</ul>
</section>
// JavaScript
var selector = ".article-list";
var paginationSelector = ".pagination";
var options = {
loadingCopy: "Loading content...",
loadCompleteCopy: "All content loaded"
};
var infiniteScroll = new NATION.InfiniteScroll(selector, paginationSelector, options);
Event that fires when a new set of content has finished loading
Event that fires when there is no more content to load
Event that fires when the first set of additional content is loaded. Useful if your application/website needs to change UI once an infinite scroll has been initiated
Event that fires when a new load request has just been sent to the server
Event that fires when a new set of content has been prepared and is ready to be inserted into the DOM
Option name | Type | Description |
---|---|---|
previousLoadOnly | boolean | If true, this will only return items from the previous load. This will return an Array, rather than a NodeList. |
return | nodelist |
Returns a NodeList of all items added in all previous loads
Re-fetches the next URL from the pagination as it currently exists and updates all selectors
This is useful if you wish to re-use the same container for a whole new set of content/pagination