'Re-init SearchWP Live Ajax Search

I'm using the SearchWP Live Ajax search in the navigation of a website in combination with BarbaJS. After a page transition (without refresh) also the navigation is being re-added and that means that I need to re-init SearchWP Live Ajax search. I can't find a way in the documentation.

https://searchwp.com/extensions/live-search/



Solution 1:[1]

Based on this repo, this part of the code worked in my scenario.

if (typeof jQuery().searchwp_live_search == 'function') {
        jQuery('input[data-swplive="true"]').searchwp_live_search();

        // Gutenberg integration is based on a body class addition because we don't have the
        // ability to manipulate the markup as we do with get_search_form().
        if(typeof _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS !== 'undefined' && _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS) {
            jQuery('input.wp-block-search__input').each(function() {
                // Append data vars.
                jQuery(this).attr('data-swpengine', _SEARCHWP_LIVE_AJAX_SEARCH_ENGINE);
                jQuery(this).attr('data-swpconfig', _SEARCHWP_LIVE_AJAX_SEARCH_CONFIG);

                // Init live search.
                jQuery(this).searchwp_live_search();
            });
        }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vincent Liong