Last active
September 23, 2020 01:22
-
-
Save jakobhans/b81caa1e688996d0079790ee1fc59394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery('input[type="checkbox"]').change(function() { | |
jQuery('#noMatchedCommunities').hide(); | |
jQuery('.matchedCommunity').removeClass('matchedCommunity'); | |
let checkedBoxes = jQuery('input[type="checkbox"]:checked').length; | |
if (checkedBoxes === 0) { | |
jQuery('ul.matches li').show(); | |
} else { | |
jQuery('ul.matches li').hide(); | |
jQuery('ul.matches li').each(function() { | |
let matches = true; | |
const communityPointer = this; | |
jQuery('input[type="checkbox"]:checked').each(function() { | |
console.log(jQuery(communityPointer).attr('class') + ' / ' + jQuery(this).attr('id')); | |
if (!jQuery(communityPointer).hasClass(jQuery(this).attr('id'))) { | |
matches = false; | |
} | |
}); | |
if (matches) { | |
jQuery(this).addClass('matchedCommunity'); | |
jQuery(this).show(); | |
} | |
}); | |
if (jQuery('.matchedCommunity').length === 0) { | |
jQuery('#noMatchedCommunities').show(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment