Skip to content

Instantly share code, notes, and snippets.

@eliorivero
Created June 18, 2015 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliorivero/b2f57b3e40596ac4ae91 to your computer and use it in GitHub Desktop.
Save eliorivero/b2f57b3e40596ac4ae91 to your computer and use it in GitHub Desktop.
Detect Infinite Scroll load
$( document ).ajaxSend(function( e, request, settings ) {
// settings.url is something like http://queryloop.com/some-paginated-view/page/2/
var page = settings.url.replace( /^(.*?)(\/page\/\d+\/)/i, '$2' ),
regex = /^\/page\/\d+\//i,
match;
if ( ( match = regex.exec( page ) ) !== null ) {
if ( match.index === regex.lastIndex ) {
regex.lastIndex++;
}
}
if ( null !== match ) {
console.log( 'Requesting ' + page );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment