FacetWP – show reset button only when facets are selected

mgibbs189

{{gist file=”test.js” lang=”javascript”}}
<script>

/*
Code placement: see the “Javascript” section on https://facetwp.com/how-to-use-hooks/
This assumes that your reset button looks like this:

<a class=”my-reset-btn” onclick=”FWP.reset()”>RESET</a>
*/

(function($) {
$(document).on(‘facetwp-loaded’, function() {
var qs = FWP.build_query_string();
if ( ” === qs ) { // no facets are selected
$(‘.your-reset-btn’).hide();
}
else {
$(‘.your-reset-btn’).show();
}
});
})(jQuery);

</script>
{{/gist}}