From e97d44baee53e481a1a53264c356e83b0f78a427 Mon Sep 17 00:00:00 2001 From: Todd Kulesza Date: Sun, 2 Feb 2014 15:35:50 -0800 Subject: [PATCH 1/2] Verify that the next selector finds a valid element upon initial load (otherwise the loading message appears and never goes away). --- jquery.jscroll.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jquery.jscroll.js b/jquery.jscroll.js index 829bdb7..d168d8b 100644 --- a/jquery.jscroll.js +++ b/jquery.jscroll.js @@ -41,7 +41,8 @@ _$window = $(window), _$body = $('body'), _$scroll = _isWindow ? _$window : $e, - _nextHref = $.trim(_$next.attr('href') + ' ' + _options.contentSelector); + _nextHref = _$next.length > 0 ? $.trim(_$next.attr('href') + ' ' + _options.contentSelector) : false; + // Initialization $e.data('jscroll', $.extend({}, _data, {initialized: true, waiting: false, nextHref: _nextHref})); @@ -99,7 +100,7 @@ innerTop = $inner.length ? $inner.offset().top : 0, iTotalHeight = Math.ceil(iTopHeight - innerTop + _$scroll.height() + iContainerTop); - if (!data.waiting && iTotalHeight + _options.padding >= $inner.outerHeight()) { + if (!data.waiting && iTotalHeight + _options.padding >= $inner.outerHeight() && _checkNextHref()) { //data.nextHref = $.trim(data.nextHref + ' ' + _options.contentSelector); _debug('info', 'jScroll:', $inner.outerHeight() - iTotalHeight, 'from bottom. Loading next request...'); return _load(); @@ -114,6 +115,7 @@ _destroy(); return false; } else { + _debug('info', 'jScroll: nextHref is "' + data.nextHref + '"'); _setBindings(); return true; } @@ -159,7 +161,7 @@ } var $next = $(this).find(_options.nextSelector).first(); data.waiting = false; - data.nextHref = $next.attr('href') ? $.trim($next.attr('href') + ' ' + _options.contentSelector) : false; + data.nextHref = ($next.length > 0 && $next.attr('href')) ? $.trim($next.attr('href') + ' ' + _options.contentSelector) : false; $('.jscroll-next-parent', $e).remove(); // Remove the previous next link now that we have a new one _checkNextHref(); if (_options.callback) { From 8122fdfb7f1f721299f43233d6198c29ccbe6a4d Mon Sep 17 00:00:00 2001 From: Todd Kulesza Date: Sun, 2 Feb 2014 15:39:44 -0800 Subject: [PATCH 2/2] Removed extra line --- jquery.jscroll.js | 1 - 1 file changed, 1 deletion(-) diff --git a/jquery.jscroll.js b/jquery.jscroll.js index d168d8b..ae4efd9 100644 --- a/jquery.jscroll.js +++ b/jquery.jscroll.js @@ -43,7 +43,6 @@ _$scroll = _isWindow ? _$window : $e, _nextHref = _$next.length > 0 ? $.trim(_$next.attr('href') + ' ' + _options.contentSelector) : false; - // Initialization $e.data('jscroll', $.extend({}, _data, {initialized: true, waiting: false, nextHref: _nextHref})); _wrapInnerContent();