Skip to content

Instantly share code, notes, and snippets.

@chadspencer
Created April 21, 2015 15:47
Show Gist options
  • Save chadspencer/2a5ccf6844549ca15214 to your computer and use it in GitHub Desktop.
Save chadspencer/2a5ccf6844549ca15214 to your computer and use it in GitHub Desktop.
$(document).on('click', 'section.sets a.ajax', function() {
var href = $(this).attr('href');
$.ajax({
url: href,
success: function(data){
console.log(data);
$('section.sets div.items').append($(data).find('section.sets div.items').html());
var href = $(data).find('section.sets a.ajax').attr('href');
$('section.sets a.ajax').attr('href', href);
$(window).on('scroll', onScroll);
}
});
history.pushState({}, '', '/lookbook/');
return false;
});
function onScroll(){
if($(window).scrollTop() + $(window).height() > $(document).height() - 200) {
$(window).off('scroll');
$('section.sets a.ajax').trigger('click');
}
}
$(window).scroll(onScroll);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment