Skip to content

Instantly share code, notes, and snippets.

@srinathweb
Created October 22, 2015 03:34
Show Gist options
  • Select an option

  • Save srinathweb/3c67d19d7215fcea0b79 to your computer and use it in GitHub Desktop.

Select an option

Save srinathweb/3c67d19d7215fcea0b79 to your computer and use it in GitHub Desktop.
load more
Have you heard about the jQuery Waypoint plugin.
Below is the simple way of calling a waypoints plugin and having the page load more Content once you reaches the bottom on scroll :
$(document).ready(function() {
var $loading = $("<div class='loading'><p>Loading more items&hellip;</p></div>"),
$footer = $('footer'),
opts = {
offset: '100%'
};
$footer.waypoint(function(event, direction) {
$footer.waypoint('remove');
$('body').append($loading);
$.get($('.more a').attr('href'), function(data) {
var $data = $(data);
$('#container').append($data.find('.article'));
$loading.detach();
$('.more').replaceWith($data.find('.more'));
$footer.waypoint(opts);
});
}, opts);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment