我正在尝试重置下拉选择字段,并在选择另一个下拉列表时更新搜索网址参数。
我正在使用启用了AJAX的wordpress的Search and Filter Pro插件,因此当我搜索时,URL会自动更改,并且只显示分配给该分类的帖子。
当选择Region下拉列表时,我使用了他们的ajax start hook来重置县下拉列表。这有效,但现在郡下拉不会独立发射,也不会做任何事情。
这是我目前正在处理的代码:
(function ( $ ) {
"use strict";
jQuery(document).on("sf:ajaxstart", ".searchandfilter", function(){
var tax1 = jQuery('.sf-field-taxonomy-regions select').val();
if(location.search.search('_sft_regions='+tax1) == -1) {
jQuery('.sf-field-taxonomy-counties select').val('');
}
});
}(jQuery));
<form data-sf-form-id='88' data-is-rtl='0' data-maintain-state='1' data-results-url='https://rslcloud.co.uk/properties-for-sale/' data-ajax-url='https://rslcloud.co.uk/properties-for-sale/?sf_data=all' data-ajax-form-url='https://rslcloud.co.uk/?sfid=88&sf_action=get_data&sf_data=form' data-display-result-method='archive' data-use-history-api='1' data-template-loaded='1' data-lang-code='' data-ajax='1' data-ajax-data-type='html' data-ajax-target='#content' data-ajax-pagination-type='normal' data-ajax-links-selector='.pagination a' data-update-ajax-url='1' data-only-results-ajax='1' data-scroll-to-pos='0' data-init-paged='1' data-auto-update='1' data-auto-count='1' data-auto-count-refresh-mode='1' action='https://rslcloud.co.uk/properties-for-sale/' method='post' class='searchandfilter' id='search-filter-form-88' autocomplete='off' data-instance-count='1'><ul><li class="sf-field-taxonomy-regions" data-sf-field-name="_sft_regions" data-sf-field-type="taxonomy" data-sf-field-input-type="select"> <label>
<span class="screen-reader-text">Browse Regions</span> <select name="_sft_regions[]" class="sf-input-select" title="Browse Regions">
<option class="sf-level-0 sf-item-0 sf-option-active" selected="selected" data-sf-count="0" data-sf-depth="0" value="">All Regions</option>
<option class="sf-level-0 sf-item-2" data-sf-count="6" data-sf-depth="0" value="east-midlands">East Midlands</option>
<option class="sf-level-0 sf-item-3" data-sf-count="8" data-sf-depth="0" value="north-west">North West</option>
<option class="sf-level-0 sf-item-5" data-sf-count="3" data-sf-depth="0" value="south">South</option>
<option class="sf-level-0 sf-item-4" data-sf-count="5" data-sf-depth="0" value="south-east">South East</option>
<option class="sf-level-0 sf-item-6" data-sf-count="1" data-sf-depth="0" value="wales">Wales</option>
<option class="sf-level-0 sf-item-7" data-sf-count="9" data-sf-depth="0" value="west-midlands">West Midlands</option>
</select>
</label> </li><li class="sf-field-taxonomy-counties" data-sf-field-name="_sft_counties" data-sf-field-type="taxonomy" data-sf-field-input-type="select"> <label>
<span class="screen-reader-text">Browse Counties</span> <select name="_sft_counties[]" class="sf-input-select" title="Browse Counties">
<option class="sf-level-0 sf-item-0 sf-option-active" selected="selected" data-sf-count="0" data-sf-depth="0" value="">All Counties</option>
<option class="sf-level-0 sf-item-8" data-sf-count="1" data-sf-depth="0" value="bedfordshire">Bedfordshire</option>
<option class="sf-level-0 sf-item-9" data-sf-count="2" data-sf-depth="0" value="berkshire">Berkshire</option>
<option class="sf-level-0 sf-item-10" data-sf-count="1" data-sf-depth="0" value="buckinghamshire">Buckinghamshire</option>
<option class="sf-level-0 sf-item-11" data-sf-count="1" data-sf-depth="0" value="cambridgeshire">Cambridgeshire</option>
<option class="sf-level-0 sf-item-12" data-sf-count="2" data-sf-depth="0" value="cheshire">Cheshire</option>
<option class="sf-level-0 sf-item-13" data-sf-count="1" data-sf-depth="0" value="conwy">Conwy</option>
<option class="sf-level-0 sf-item-14" data-sf-count="1" data-sf-depth="0" value="dorset">Dorset</option>
<option class="sf-level-0 sf-item-15" data-sf-count="3" data-sf-depth="0" value="east-sussex">East Sussex</option>
<option class="sf-level-0 sf-item-16" data-sf-count="1" data-sf-depth="0" value="lancashire">Lancashire</option>
<option class="sf-level-0 sf-item-17" data-sf-count="1" data-sf-depth="0" value="leicestershire">Leicestershire</option>
<option class="sf-level-0 sf-item-18" data-sf-count="1" data-sf-depth="0" value="lincolnshire">Lincolnshire</option>
<option class="sf-level-0 sf-item-19" data-sf-count="1" data-sf-depth="0" value="london">London</option>
<option class="sf-level-0 sf-item-20" data-sf-count="4" data-sf-depth="0" value="merseyside">Merseyside</option>
<option class="sf-level-0 sf-item-21" data-sf-count="1" data-sf-depth="0" value="middlesex">Middlesex</option>
<option class="sf-level-0 sf-item-22" data-sf-count="1" data-sf-depth="0" value="northamptonshire">Northamptonshire</option>
<option class="sf-level-0 sf-item-23" data-sf-count="2" data-sf-depth="0" value="warwickshire">Warwickshire</option>
<option class="sf-level-0 sf-item-24" data-sf-count="5" data-sf-depth="0" value="west-midlands">West Midlands</option>
<option class="sf-level-0 sf-item-25" data-sf-count="1" data-sf-depth="0" value="wiltshire">Wiltshire</option>
<option class="sf-level-0 sf-item-26" data-sf-count="1" data-sf-depth="0" value="wirral">Wirral</option>
<option class="sf-level-0 sf-item-27" data-sf-count="2" data-sf-depth="0" value="worcestershire">Worcestershire</option>
</select>
</label> </li></ul></form>
<select name="choose-court" onchange="location = this.value;">
<option>Choose Court</option>
<option value="ashby-court">Ashby Court</option>
<option value="blake-court">Blake Court</option>
<option value="blundellsands-classic">Blundellsands Classic Court</option>
<option value="boat-lane-court">Boat Lane Court</option>
<option value="bowling-green-court">Bowling Green Court</option>
<option value="burcot-court">Burcot Court</option>
<option value="bushmead-court">Bushmead Court</option>
<option value="carrs-court">Carrs Court</option>
<option value="cathedral-green-court">Cathedral Green Court</option>
<option value="deerhurst-court">Deerhurst Court</option>
<option value="dovehouse-court">Dovehouse Court</option>
<option value="elizabeth-court">Elizabeth Court</option>
<option value="emmbrook-court">Emmbrook Court</option>
<option value="forum-court">Forum Court</option>
<option value="fullerton-court">Fullerton Court</option>
<option value="gorselands-court">Gorselands Court</option>
<option value="greyfriars-court">Greyfriars Court</option>
<option value="kennet-court">Kennet Court</option>
<option value="king-richard-court">King Richard Court</option>
<option value="margaret-court">Margaret Court</option>
<option value="marlborough-court">Marlborough Court</option>
<option value="melton-court">Melton Court</option>
<option value="minster-court">Minster Court</option>
<option value="oaktree-court">Oaktree Court</option>
<option value="osborne-court">Osborne Court</option>
<option value="pinner-court">Pinner Court</option>
<option value="plymouth-court">Plymouth Court</option>
<option value="plymouth-court-2">Plymouth Court</option>
<option value="priory-court">Priory Court</option>
<option value="saxon-court">Saxon Court</option>
<option value="st-georges-court">St Georges Court</option>
<option value="tannery-court">Tannery Court</option>
<option value="tiddington-court">Tiddington Court</option>
</select>
</div>
rslcloud.co.uk/properties-for-sale /
有谁知道为什么县下降现在不起作用?