Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save erichuang2015/f82ab7c1af31d8f200cac4bce39a6311 to your computer and use it in GitHub Desktop.
Save erichuang2015/f82ab7c1af31d8f200cac4bce39a6311 to your computer and use it in GitHub Desktop.
Ajax Load More - Filtering
$(function() {
// Filter Ajax Load More
var alm_is_animating = false;
$('#alm-filter-nav li').eq(0).addClass('active'); // Set the initial button active state
// Nav btn click event
$('#alm-filter-nav li a').on('click', function(e){
e.preventDefault();
var el = $(this); // Our selected element
if(!el.hasClass('active') && !alm_is_animating){ // Check for active and !alm_is_animating
alm_is_animating = true;
el.parent().addClass('active').siblings('li').removeClass('active'); // Add active state
var data = el.data(), // Get data values from selected menu item
transition = 'fade', // 'slide' | 'fade' | null
speed = '300'; //in milliseconds
$.fn.almFilter(transition, speed, data); // reset Ajax Load More (transition, speed, data)
}
});
$.fn.almFilterComplete = function(){
alm_is_animating = false; // clear alm_isanimating flag
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment