Created
June 18, 2015 20:47
-
-
Save eliorivero/b2f57b3e40596ac4ae91 to your computer and use it in GitHub Desktop.
Detect Infinite Scroll load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( 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