早上好
我正在尝试实现过滤器功能。我有多个要过滤的字段,但让我真正头疼的一个是包含行李的单选按钮字段。
在我只有真或假选项之前。但是由于没有意义,如果用户不关心行李,我就需要第三种选择(这里称为“任意”)。
如果他选择ANY作为他的选择,我将取回所有结果,无论它们的值是true还是false。 该如何解决?
<div id="filter__BaggageIncluded">
<div class="custom-controls-stacked">
<div class="custom-control custom-radio">
<input id="select__BaggageIncluded_any" name="select__BaggageIncluded" type="radio" value="any" class="custom-control-input" checked />
<label class="custom-control-label" for="select__BaggageIncluded_any">any</label>
</div>
<div class="custom-control custom-radio">
<input id="select__BaggageIncluded_true" name="select__BaggageIncluded" type="radio" value="true" class="custom-control-input" />
<label class="custom-control-label" for="select__BaggageIncluded_true">yes</label>
</div>
<div class="custom-control custom-radio">
<input id="select__BaggageIncluded_false" name="select__BaggageIncluded" type="radio" value="false" class="custom-control-input" />
<label class="custom-control-label" for="select__BaggageIncluded_false">no</label>
</div>
</div>
</div>
function SetFilter() {
return $("#select__BaggageIncluded_" + $(this).data("baggage")).is(":checked");
}
/*The divs to be filtered look like this:*/
<div data-baggageincluded="true">...</div>
or
<div data-baggageincluded="false">...</div>