FacetWP – add CSS class to active facets

mgibbs189

{{gist file=”test.js” lang=”javascript”}}
(function($) {
$(document).on(‘facetwp-loaded’, function() {
$.each(FWP.facets, function(name, vals) {
if (FWP.facets[name].length > 0) {
$(‘.facetwp-facet-‘ + name).addClass(‘is-active’);
}
else {
$(‘.facetwp-facet-‘ + name).removeClass(‘is-active’);
}
});
});
})(jQuery);
{{/gist}}