我能够在页面加载时自动将span类中的文本复制到输入字段,但即使在使用FacetWP时,也无法使FWP.refresh()响应和更新结果
https://facetwp.com/documentation/developers/javascript/facetwp-refresh/
小面名称- proximity
Span类- local-addrress-name
输入类- 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">
发布于 2019-11-22 21:55:25
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('');
});https://stackoverflow.com/questions/59000946
复制相似问题