Skip to content

Instantly share code, notes, and snippets.

@heylastway
Created October 31, 2019 15:02
Show Gist options
  • Save heylastway/840870920d269f01f9d0b1ac97c31db3 to your computer and use it in GitHub Desktop.
Save heylastway/840870920d269f01f9d0b1ac97c31db3 to your computer and use it in GitHub Desktop.
//Infinite scroll
$(document).ready(function(){
$('#Loader').on('inview', function(event, isInView) {
if (isInView) {
var nextPage = parseInt($('#pageno').val())+1;
//Filters
var minimum_wt = $('#hidden_minimum_wt').val();
var maximum_wt = $('#hidden_maximum_wt').val();
var shape = get_filter('shape');
var color = get_filter('color');
var enhancement = get_filter('enhancement');
var matching = get_filter('matching');
$.ajax({
type: 'POST',
url: 'vendors/php/NextPage.php',
data: {
pageno: nextPage,
minimum_wt: minimum_wt,
maximum_wt: maximum_wt,
shape: shape,
color: color,
enhancement: enhancement,
matching: matching
},
success: function(data){
if(data != ''){
$('#StoneContainer').append(data);
$('.LoaderContainer').hide(); //Hide infinite scroll
$('#pageno').val(nextPage);
} else {
$('#StoneContainer').append(data);
$('.LoaderContainer').show(); //Show infinite scroll
}
}
});
}
});
});
//Checking applied filters
function get_filter(class_name) {
var filter = [];
$('.'+class_name+':checked').each(function(){
filter.push($(this).val());
});
return filter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment