Re-trigger Dynamic.ooo’s Dynamic archives widget accordion after AJAX refresh

<?php
// The .accordionjs class in line 9 is the class of the ul that is the accordion wrapper. Adapt if needed.
add_action( 'facetwp_scripts', function() {
  ?>
  <script>
    (function($) {
      document.addEventListener('facetwp-loaded', function() {
        if ( FWP.loaded ) {
          $('.accordionjs').accordionjs( {
            activeIndex: false // This prevents the first section from opening by default. Remove this option if you want that to happen.
          } );
        }
      });
    })(jQuery);
  </script>
  <?php
}, 100 );