将跨度 class 内的文本拉到 FacetWP Proximity Input 文本字段

Pull text from within span class to FacetWP Proximity Input text field

我可以在页面加载时自动将跨度 class 内的文本复制到输入字段,但我无法让 FacetWP 响应并更新结果,即使使用 FWP.refresh()

https://facetwp.com/documentation/developers/javascript/facetwp-refresh/

构面名称 - proximity

跨度 class - local-addrress-name

输入class - facetwp-location

window.addEventListener('load', function () {
var nodes = document.querySelectorAll('.local-address-name');
var last = nodes[nodes.length- 1];
document.querySelector('.facetwp-location').value =last.innerHTML;
  setTimeout(function() {  
FWP.refresh(); // Change a facet value
         console.log( "ready!" );
  }, 2000);

    
});
<span class="local-address-name">Brunswick, GA, USA</span>

<input type="text" class="facetwp-location" value="" placeholder="Enter Zip or Address" id="facetwp-location" autocomplete="off">

FacetWP 依靠隐藏的 lat/lng 字段来完成繁重的工作,然后只是同步所有内容。这是一种通过每个产品页面上的 lat/lng 位置接近度来实现相关产品的简单方法。干杯!

window.addEventListener('load', function () {
var nodes = document.querySelectorAll('.local-address-name');
var last = nodes[nodes.length- 1];
document.querySelector('.facetwp-location').value =last.innerHTML;
});

window.addEventListener('load', function () {
var nodes = document.querySelectorAll('.local-lat-val');
var last = nodes[nodes.length- 1];
document.querySelector('.facetwp-lat').value =last.innerHTML;
});

window.addEventListener('load', function () {
var nodes = document.querySelectorAll('.local-lng-val');
var last = nodes[nodes.length- 1];
document.querySelector('.facetwp-lng').value =last.innerHTML;
FWP.refresh('');
});