11/*!
2- * Infinite Scroll PACKAGED v3.0.1
2+ * Infinite Scroll PACKAGED v3.0.2
33 * Automatically add next page
44 *
55 * Licensed GPLv3 for open source use
@@ -1211,10 +1211,13 @@ proto.stopPrefill = function() {
12111211
12121212function request ( url , responseType , onLoad , onError ) {
12131213 var req = new XMLHttpRequest ( ) ;
1214- req . open ( 'GET' , url ) ;
1214+ req . open ( 'GET' , url , true ) ;
12151215 // set responseType document to return DOM
12161216 req . responseType = responseType || '' ;
12171217
1218+ // set X-Requested-With header to check that is ajax request
1219+ req . setRequestHeader ( 'X-Requested-With' , 'XMLHttpRequest' ) ;
1220+
12181221 req . onload = function ( ) {
12191222 if ( req . status == 200 ) {
12201223 onLoad ( req . response ) ;
@@ -1643,7 +1646,7 @@ InfiniteScrollButton.prototype.hide = function() {
16431646} ;
16441647
16451648InfiniteScrollButton . prototype . destroy = function ( ) {
1646- this . element . removeEventListener ( this . clickHandler ) ;
1649+ this . element . removeEventListener ( 'click' , this . clickHandler ) ;
16471650} ;
16481651
16491652// -------------------------- -------------------------- //
@@ -1704,8 +1707,12 @@ InfiniteScroll.create.status = function() {
17041707 this . on ( 'request' , this . showRequestStatus ) ;
17051708 this . on ( 'error' , this . showErrorStatus ) ;
17061709 this . on ( 'last' , this . showLastStatus ) ;
1710+ this . bindHideStatus ( 'on' ) ;
1711+ } ;
1712+
1713+ proto . bindHideStatus = function ( bindMethod ) {
17071714 var hideEvent = this . options . append ? 'append' : 'load' ;
1708- this . on ( hideEvent , this . hideAllStatus ) ;
1715+ this [ bindMethod ] ( hideEvent , this . hideAllStatus ) ;
17091716} ;
17101717
17111718proto . showRequestStatus = function ( ) {
@@ -1718,6 +1725,8 @@ proto.showErrorStatus = function() {
17181725
17191726proto . showLastStatus = function ( ) {
17201727 this . showStatus ( 'last' ) ;
1728+ // prevent last then append event race condition from showing last status #706
1729+ this . bindHideStatus ( 'off' ) ;
17211730} ;
17221731
17231732proto . showStatus = function ( eventName ) {
@@ -1762,7 +1771,7 @@ return InfiniteScroll;
17621771} ) ) ;
17631772
17641773/*!
1765- * Infinite Scroll v3.0.1
1774+ * Infinite Scroll v3.0.2
17661775 * Automatically add next page
17671776 *
17681777 * Licensed GPLv3 for open source use
0 commit comments