简体   繁体   English

FacetWP 过滤器 - 单击单选按钮重置 facet

[英]FacetWP Filters - Reset facets on click of a radiobutton

does anyone work with FacetWP?有人使用 FacetWP 吗? I am trying to reset certain filters if the user selects one of the radio options from the facet "ex_type".如果用户从构面“ex_type”中选择了一个单选选项,我将尝试重置某些过滤器。

If one any of the radio options are selected, I want this to then reset the other facets automatically.如果选择了任何一个单选选项,我希望它可以自动重置其他方面。

Facetwp have a function "onclick="FWP.reset()" however from the backend I cannot access the radio buttons. I need to target the radio button choices with a separate jquery function as below, however my code is not working. Facetwp 有一个函数 "onclick="FWP.reset()" 但是从后端我无法访问单选按钮。我需要使用单独的 jquery 函数来定位单选按钮选项,如下所示,但是我的代码不起作用。

Here is the view from my backend:这是我后端的视图:

<div class="group-individual">                                                              

    <?php echo facetwp_display( 'facet', 'ex_type'); ?>

</div>      

<div class="sub-filters" >

        <div class="day">                                   

            <?php echo facetwp_display( 'facet', 'day' ); ?>

        </div>

        <div class="time">

            <?php echo facetwp_display( 'facet', 'time' ); ?>

        </div>

</div><!--sub-filters-->    

The actual code for the "ex_type" radio buttons displayed is this:显示的“ex_type”单选按钮的实际代码是这样的:

<div class="group-individual">

<div class="facetwp-facet facetwp-type-radio" data-name="ex_type" data-type="radio">

    <div class="facet-wrapper">

        <div class="facetwp-radio" data-value="classes">
        "classes"
        </div>

        <div class="facetwp-radio" data-value="individual">
        "individaul"
        </div>

    </div>

</div>

</div>

I have tried to refresh the other facet choices with a click function but it is not working.我试图用点击功能刷新其他方面的选择,但它不起作用。 The code I have tried is:我试过的代码是:

<script>
$(document).ready(
   function(){
     $(".facetwp-radio").click(function () {   
       FWP.reset('day');
     });
}); 
</script>

And also this:还有这个:

<script>
$(document).ready(
   function(){
     $(".facetwp-radio").click(function () {   
        FWP.facets['day'] = []; 
        FWP.facets['time'] = []; 
     });
}); 
</script>

Any suggestions welcomed.欢迎任何建议。 Thank you.谢谢。

According to Facet WP's documentation , you could add the following html in order to reset the wanted facet : <button onclick="FWP.reset('day')">Reset Day</button> .根据Facet WP 的文档,您可以添加以下 html 以重置想要的 facet : <button onclick="FWP.reset('day')">Reset Day</button>

All you finally need to do, is some customization over this button.您最终需要做的就是对这个按钮进行一些自定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM