Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a new "nextHrefAttribute" option #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ $('.jscroll').jscroll({

## Options

* debug (false) When set to true, outputs useful information to the console display if the `console` object exists.
* autoTrigger (true) When set to true, triggers the loading of the next set of content automatically when the user scrolls to the bottom of the containing element. When set to false, the required next link will trigger the loading of the next set of content when clicked.
* autoTriggerUntil (false) Set to an integer great than 0 to turn off `autoTrigger` of paging after the specified number of pages. Requires `autoTrigger` to be `true`.
* loadingHtml (`'<small>Loading...</small>'`) The HTML to show at the bottom of the content while loading the next set.
* padding (0) The distance from the bottom of the scrollable content at which to trigger the loading of the next set of content. This only applies when autoTrigger is set to true.
* nextSelector ('a:last') The selector to use for finding the link which contains the href pointing to the next set of content. If this selector is not found, or if it does not contain a href attribute, jScroll will self-destroy and unbind from the element upon which it was called.
* contentSelector ('') A convenience selector for loading only part of the content in the response for the next set of content. This selector will be ignored if left blank and will apply the entire response to the DOM.
* pagingSelector ('') Optionally define a selector for your paging controls so that they will be hidden, instead of just hiding the next page link.
* callback () Optionally define a callback function to be called after a set of content has been loaded.
* debug (false) When set to true, outputs useful information to the console display if the `console` object exists.
* autoTrigger (true) When set to true, triggers the loading of the next set of content automatically when the user scrolls to the bottom of the containing element. When set to false, the required next link will trigger the loading of the next set of content when clicked.
* autoTriggerUntil (false) Set to an integer great than 0 to turn off `autoTrigger` of paging after the specified number of pages. Requires `autoTrigger` to be `true`.
* loadingHtml (`'<small>Loading...</small>'`) The HTML to show at the bottom of the content while loading the next set.
* padding (0) The distance from the bottom of the scrollable content at which to trigger the loading of the next set of content. This only applies when autoTrigger is set to true.
* nextSelector ('a:last') The selector to use for finding the link which contains the href pointing to the next set of content. If this selector is not found, or if it does not contain a href attribute, jScroll will self-destroy and unbind from the element upon which it was called.
* nextHrefAttribute ('href') The html attribute where the next page url is contained. This allows to use html5 data attributes to to store the next page url.
* contentSelector ('') A convenience selector for loading only part of the content in the response for the next set of content. This selector will be ignored if left blank and will apply the entire response to the DOM.
* pagingSelector ('') Optionally define a selector for your paging controls so that they will be hidden, instead of just hiding the next page link.
* callback () Optionally define a callback function to be called after a set of content has been loaded.

For more information on the *contentSelector* option and how it loads a response fragment, see the [jQuery documentation for the .load() method](http://api.jquery.com/load/).

Expand Down
5 changes: 3 additions & 2 deletions jquery.jscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
loadingHtml: '<small>Loading...</small>',
padding: 0,
nextSelector: 'a:last',
nextHrefAttribute: 'href',
contentSelector: '',
pagingSelector: '',
callback: false
Expand All @@ -41,7 +42,7 @@
_$window = $(window),
_$body = $('body'),
_$scroll = _isWindow ? _$window : $e,
_nextHref = $.trim(_$next.attr('href') + ' ' + _options.contentSelector);
_nextHref = $.trim(_$next.attr(options.nextHrefAttribute) + ' ' + _options.contentSelector);

// Initialization
$e.data('jscroll', $.extend({}, _data, {initialized: true, waiting: false, nextHref: _nextHref}));
Expand Down Expand Up @@ -159,7 +160,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.attr(_options.nextHrefAttribute) ? $.trim($next.attr(_options.nextHrefAttribute) + ' ' + _options.contentSelector) : false;
$('.jscroll-next-parent', $e).remove(); // Remove the previous next link now that we have a new one
_checkNextHref();
if (_options.callback) {
Expand Down
2 changes: 1 addition & 1 deletion jquery.jscroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.