Overview

This JS event gets triggered when FacetWP finishes refreshing. It’s triggered after a user interacts with a facet or pagination control. This event is useful for modifying facet output after being rendered.

Usage

Example 1: scroll to the top of the page after an ajax refresh:

<?php
add_action( 'wp_footer', function() {
?>
<script>
document.addEventListener('facetwp-loaded', function() {
    window.scrollTo({ top: 0, behavior: 'smooth' });
});
</script>
<?php
}, 100 );

Example 2: reinitialize Jetpack Lazy Load after an ajax refresh:

<?php
add_action( 'wp_footer', function() {
?>
<script>
document.addEventListener('facetwp-loaded', function() {
    fUtil('body').trigger('jetpack-lazy-images-load');
});
</script>
<?php
}, 100 );

More examples

See also