Skip to content

Instantly share code, notes, and snippets.

@dacur
Created February 9, 2015 17:03
Show Gist options
  • Save dacur/7b6507edc1eac5958f65 to your computer and use it in GitHub Desktop.
Save dacur/7b6507edc1eac5958f65 to your computer and use it in GitHub Desktop.
Every time a filter is applied/clicked, check to see if any items are displayed on the page. If not, display the message "Your search did not return any results. Please try again.". The message is hidden by default. The searches are fired on the click of a dropdown item. This function is called from each search function.
function DoesFilterReturnZeroItems(){
var hiddenItems = 0;
var allItems = 0;
$('#closetItems').find('.closetWrapper').each(function(){
if($(this).hasClass('displaynone')){
hiddenItems++;
}
allItems++;
});
if(allItems==hiddenItems){
$('#noItemsReturnedCloset').removeClass('displaynone');
} else {
if(!$('#noItemsReturnedCloset').hasClass('displaynone')){
$('#noItemsReturnedCloset').addClass('displaynone');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment