Hi @tijmensmit
Thank you for taking the time to respond!
I hope you’re feeling well!
Yes, of course I used .trigger(), I added some buttons using some similar code:
window.addEventListener("DOMContentLoaded", function () {
$(document).ready(function() {
$("#CUSTOM_BTN_ID_1").click(function() {
$("#wpsl-search-input").val("SOME_STATE_VALUE_1");
$("#wpsl-radius-dropdown").val("SOME_RADIUS_VALUE_1");
$( "#wpsl-radius .wpsl-dropdown .wpsl-selected-item" ).attr( "data-value", "SOME_RADIUS_VALUE_1" );
$("#wpsl-search-btn").trigger("click");
});
});
$(document).ready(function() {
$("#CUSTOM_BTN_ID_2").click(function() {
$("#wpsl-search-input").val("SOME_STATE_VALUE_2");
$("#wpsl-radius-dropdown").val("SOME_RADIUS_VALUE_2");
$( "#wpsl-radius .wpsl-dropdown .wpsl-selected-item" ).attr( "data-value", "SOME_RADIUS_VALUE_2" );
$("#wpsl-search-btn").trigger("click");
});
});
});
everything works as I planned, except for one problem:
when I click on the first button, my script works correctly, I see what I need on the map and see the corresponding results in the list.
But if after that I click on any other custom button, the results will start to get confused, for example, the marker of the previous search result will remain on the map, but the results in the list will be correct, or the previous results will remain in the list of results, and a new marker will appear on the map. This applies to all subsequent button clicks. BUT, if I click the same button twice, the results will be correct again.
It looks like there is no reset of some parameters after clicking on the next custom button.
Thanks!