首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重新插入SearchWP Live搜索

重新插入SearchWP Live搜索
EN

Stack Overflow用户
提问于 2021-11-03 11:06:39
回答 1查看 93关注 0票数 0

我正在使用SearchWP Live搜索结合BarbaJS导航一个网站。在页面转换(没有刷新)之后,导航也将被重新添加,这意味着我需要重新插入SearchWP Live搜索。我在文件里找不到办法。

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

EN

回答 1

Stack Overflow用户

发布于 2022-05-03 13:54:32

基于这个存储库,代码的这一部分在我的场景中工作。

代码语言:javascript
复制
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();
            });
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69823776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档