1
1
/*!
2
- * Infinite Scroll PACKAGED v3.0.1
2
+ * Infinite Scroll PACKAGED v3.0.2
3
3
* Automatically add next page
4
4
*
5
5
* Licensed GPLv3 for open source use
@@ -1211,10 +1211,13 @@ proto.stopPrefill = function() {
1211
1211
1212
1212
function request ( url , responseType , onLoad , onError ) {
1213
1213
var req = new XMLHttpRequest ( ) ;
1214
- req . open ( 'GET' , url ) ;
1214
+ req . open ( 'GET' , url , true ) ;
1215
1215
// set responseType document to return DOM
1216
1216
req . responseType = responseType || '' ;
1217
1217
1218
+ // set X-Requested-With header to check that is ajax request
1219
+ req . setRequestHeader ( 'X-Requested-With' , 'XMLHttpRequest' ) ;
1220
+
1218
1221
req . onload = function ( ) {
1219
1222
if ( req . status == 200 ) {
1220
1223
onLoad ( req . response ) ;
@@ -1643,7 +1646,7 @@ InfiniteScrollButton.prototype.hide = function() {
1643
1646
} ;
1644
1647
1645
1648
InfiniteScrollButton . prototype . destroy = function ( ) {
1646
- this . element . removeEventListener ( this . clickHandler ) ;
1649
+ this . element . removeEventListener ( 'click' , this . clickHandler ) ;
1647
1650
} ;
1648
1651
1649
1652
// -------------------------- -------------------------- //
@@ -1704,8 +1707,12 @@ InfiniteScroll.create.status = function() {
1704
1707
this . on ( 'request' , this . showRequestStatus ) ;
1705
1708
this . on ( 'error' , this . showErrorStatus ) ;
1706
1709
this . on ( 'last' , this . showLastStatus ) ;
1710
+ this . bindHideStatus ( 'on' ) ;
1711
+ } ;
1712
+
1713
+ proto . bindHideStatus = function ( bindMethod ) {
1707
1714
var hideEvent = this . options . append ? 'append' : 'load' ;
1708
- this . on ( hideEvent , this . hideAllStatus ) ;
1715
+ this [ bindMethod ] ( hideEvent , this . hideAllStatus ) ;
1709
1716
} ;
1710
1717
1711
1718
proto . showRequestStatus = function ( ) {
@@ -1718,6 +1725,8 @@ proto.showErrorStatus = function() {
1718
1725
1719
1726
proto . showLastStatus = function ( ) {
1720
1727
this . showStatus ( 'last' ) ;
1728
+ // prevent last then append event race condition from showing last status #706
1729
+ this . bindHideStatus ( 'off' ) ;
1721
1730
} ;
1722
1731
1723
1732
proto . showStatus = function ( eventName ) {
@@ -1762,7 +1771,7 @@ return InfiniteScroll;
1762
1771
} ) ) ;
1763
1772
1764
1773
/*!
1765
- * Infinite Scroll v3.0.1
1774
+ * Infinite Scroll v3.0.2
1766
1775
* Automatically add next page
1767
1776
*
1768
1777
* Licensed GPLv3 for open source use
0 commit comments