facetwp-refresh

Overview

This jQuery event gets triggered before FacetWP begins the refresh process. It happens before any AJAX is requested, and before the URL hash gets updated. This event is useful for modifying any FWP variables before getting sent to the server.

Usage

Override facet value:

<script>
(function($) {
    $(document).on('facetwp-refresh', function() {
        FWP.facets['vehicle_type'] = ['car']; // Change a facet value
     });
})(jQuery);
</script>

Clear facet A’s value if a value for facet B is selected:

<script>
(function($) {
    $(document).on('facetwp-refresh', function() {
        if (FWP.facets['facet_b'].length > 0) {
            FWP.facets['facet_a'] = [];
        }
     });
})(jQuery);
</script>

More examples

See Also

facetwp-loaded

How FacetWP stores its javascript data