It is possible to set the bottom margin used for pagination on scroll
(default is 1 pixel). For example, if you want the pagination on scroll
to be activated when 20 pixels remain to the end of the page:

Both callbacks also receive a context argument containing information about
the requested page:

context.url: the requested URL;

context.key: the querystring key used to retrieve the requested contents.

If the onClick callback returns false, the pagination process is stopped,
the Ajax request is not performed and the onCompleted callback never called.

The onCompleted callbacks also receives a second argument: the data returned
by the server. Basically this is the HTML fragment representing the new
requested page.

To wrap it up, here is an example showing the callbacks’ signatures:

<h2>Entries:</h2><divclass="endless_page_template">{%includepage_template%}</div>{%blockjs%}{{block.super}}<scriptsrc="http://code.jquery.com/jquery-latest.js"></script><scriptsrc="{{STATIC_URL}}endless_pagination/js/endless-pagination.js"></script><script>$.endlessPaginate({onClick:function(context){console.log('Label:',$(this).text());console.log('URL:',context.url);console.log('Querystring key:',context.key);if(forbidden){// to be defined...returnfalse;}},onCompleted:function(context,fragment){console.log('Label:',$(this).text());console.log('URL:',context.url);console.log('Querystring key:',context.key);console.log('Fragment:',fragment);}});</script>{%endblock%}

The call to $(‘#entries’).endlessPaginate() applies Ajax pagination starting
from the DOM node with id entries and to all sub-nodes. This means that
other entries are left intact. Of course you can use any selector supported
by jQuery.

At this point, you might have already guessed that $.endlessPaginate()
is just an alias for $(‘body’).endlessPaginate().

Here the #entries node is selected and Digg-style pagination is applied.
Digg-style needs to know which DOM node will be updated with new contents,
and in this case it’s the same node we selected, because we added the
endless_page_template class to that node, and .endless_page_template
is the selector used by default. However, the following example is equivalent
and does not involve adding another class to the container:

Sometimes, when using on scroll pagination, you may want to still display
the show more link after each N pages. In Django Endless Pagination this is
called chunk size. For instance, a chunk size of 5 means that a show more
link is displayed after page 5 is loaded, then after page 10, then after page
15 and so on. Activating this functionality is straightforward, just use the
paginateOnScrollChunkSize option:

Django Endless Pagination v2.0 introduces changes in how Ajax pagination
is handled by JavaScript. These changes are discussed in this document and in
the Changelog.

The JavaScript code now lives in a file named endless-pagination.js.
For backward compatibility, the application still includes the two JavaScript
files endless.js and endless_on_scroll.js. However, please consider
migrating as soon as possible: the old JavaScript files are deprecated, are
no longer maintained, and don’t provide the new JavaScript features.

Instructions on how to migrate from the old version to the new one follow.