Home › Toolset Professional Support › [Waiting for user confirmation] Search by location using Toolset Maps no longer working correctly
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| - | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
| - | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 27 replies, has 1 voice.
Last updated by Minesh 1 day, 5 hours ago.
Assisted by: Minesh.
HI Minesh
Thanks for the update, however it doesn't really help me.
We had a working Location feature, we moved hosts, and now it is not working as before. I fully expect Toolset Support to be able to tell us the technical reason why it is no longer working. We didn't change any configuration, so it should continue to work as it did before the migration to the new host.
Thanks and kind regards
Simon
I checked the site cloned at cloudwaysapps.com but that does not work as expected and I think its better to test on your new server.
Can you provide a test site/staging site on your new hosting and share access details and let me try to check and run few test on that and check whats going on.
I have set the next reply to private which means only you and I have access to it.
Just to double check with you - the dev/staging site is also hosted on the same new server. Is that correct?
Hi Minesh
Yes, both on new host.
Kind regards
Simon
Hi Minesh
I kindly ask you again to ask your colleague Christopher to DELETE the copy of our production site which he took. It is still sending us automated emails, despite my previous deletion request from 31/10.
Thanks and best regards
Simon
The issue looks like when you spit the view parts to display search form in one part and search result in different part - it fires two ajax requests and due to that the address search box is affected.
Can you please check now: hidden link
To yoru view I've added the following custom JS code:
=> hidden link
jQuery(document).ready(function($){
let activeToolsetAjax = null;
$(document).ajaxSend(function(event, jqXHR, settings) {
// Only target Toolset search AJAX calls
if (settings.data && settings.data.indexOf('action=wpv_get_view_query_results') !== -1) {
// If a Toolset request is already running, cancel this new one (the duplicate)
if (activeToolsetAjax && activeToolsetAjax.readyState !== 4) {
// console.log('Blocked duplicate Toolset AJAX request');
jqXHR.abort(); // cancel the second request
return;
}
// Otherwise, mark this as the active one
activeToolsetAjax = jqXHR;
// When it finishes, clear the tracker
jqXHR.always(function() {
activeToolsetAjax = null;
});
}
});
});
Can you please confirm it works as exxpected.
Regarding deleting your site, Christopher is on vacation, I have raise your query to delete your site in front of concern person and I will get back to you with updates when I have on it.
Update:
- Your site copy is deleted from the cloudwaysapp server.
Hi Minesh
1) So, is this code intended to be generic for all Views? In other words, can I apply the same code to Find a Native Nanny Search and Results View in dev, and to those two Views in Production? (I'm not sure I understand what "jqXHR" is, for example, if it's something specific to that View or not.)
2) On testing, it seems to work partially:
I noticed that when only one result is returned under Find a Job, it is getting distorted ("squeezed" - see screenshot - with 2 or more results, it is showing correctly). It's the first time I'm seeing such behaviour and it is not happening like that on our Production site. Nor is it happening on dev Find a Native Nanny view, (see screenshot), where one result is displayed correctly at its normal width, you can compare using the Locations used in my screenshots.
I cleared the WP Rocket cache (WP Rocket admin menu > Clear Priority Elements). Then it worked briefly again normally when I refreshed the page, but searching again on another location is returning to that distorted view, only when there is one result.
Kind regards
Simon
1) So, is this code intended to be generic for all Views? In other words, can I apply the same code to Find a Native Nanny Search and Results View in dev, and to those two Views in Production? (I'm not sure I understand what "jqXHR" is, for example, if it's something specific to that View or not.)
====>
Yes, you can add the same code to your desired respective view's custom JS box.
However - this is just workaround, the best method for now is to switch to non-ajax mode that is filter view result when user click on submit button.
I will report this issue but I'm not sure how long it will take in order to fix the issue due to pre-defined priority of Devs for other urgent issue.
Regarding the another issue - just to observe is is side effect of the code I added, what if you remove the JS code I shared, do you see the same issue when you have one result.
HI Minesh
I commented out your code, but can still reproduce. I tested bypassing the WP Rocket Cache as well for that URL by appending
?nowprocket
to the URL, but I can still reproduce it with and without. It was definitely not like before, it's the first time I'm seeing such a thing. Using both URLs below it SOMETIMES happens, but not EVERY time. It's not working reliably.
Using Location = "Aschaffenburg, Germany" produces only one result on Find a Job, for example:
With WP Rocket cacheing active:
hidden link
Bypassing WP Rocket cache:
hidden link
Kind regards
Simon
You already know - with time, WordPress, other addon plugins, themes evething thing will have updates and its really hard to pinpoint whats causing this.
Seeing all this issues, I see moving to non-ajax mode that is filter view result when user click on submit button is only the best option for you currently.
Even though I report this issue, I'm not sure when the fix will be made available. I hope this is understandable. You may want to switch to non-ajax mode to have smooth accessibility without any issues.
As I shared before - I will report this issue but I'm not sure how long it will take in order to fix the issue due to pre-defined priority of Devs for other urgent issue.
Hi Minesh
And, as you already know, Toolset Support also needs to adapt to the constantly changing circumstances. In that light, can you please refrain from repeatedly suggesting moving back to non-AJAX as a solution. It is NOT an acceptable resolution to this ticket. The Location is our principle search criteria and this functionality has to continue to work with AJAX, as it has done for years without a problem.
Even with bare minimal required plugins active to keep the dev site secure and usuable (as is the current state on dev.native-nanny.de), I am able to reproduce the new erroneous behaviour with the "squeezing" of the Search Results.
I kindly request you to troubleshoot and debug to find the problem, conferring with your helpful colleagues if necessary, otherwise I will have to request escalation. It cannot be blamed on cache or otherwise since this has all been deactivated on dev.
Kind regards
Simon
Ok as per your requirest as you do not want to go with the non-ajax filter workaround, I've escalted the ticket to our next level support. Please hold on further update on that and there is no ETA on it.
For AJAX workaround, I've adjusted the code added to your view's "Search and Pagination" section's JS editor as given under:
=> hidden link
function initGermanAddressAutocomplete() {
const input = document.getElementById('toolset-maps-distance-center');
if (!input) {
console.warn('Autocomplete input not found yet.');
return;
}
// Prevent duplicate initializations
if (input.dataset.autocompleteInitialized) return;
input.dataset.autocompleteInitialized = true;
// Initialize the Google Maps Places Autocomplete
const autocomplete = new google.maps.places.Autocomplete(input, {
componentRestrictions: { country: "de" }, // Restrict to Germany
});
autocomplete.addListener("place_changed", function() {
const place = autocomplete.getPlace();
});
}
function setupGermanAddressAutocompleteEvents() {
// Initialize once when the page first loads
initGermanAddressAutocomplete();
// Re-initialize after Toolset AJAX search refresh
jQuery(document).on('js_event_wpv_parametric_search_form_updated', function (event, data ) {
setTimeout(initGermanAddressAutocomplete, 300); // small delay ensures input exists
});
}
// Run setup when DOM is ready
jQuery(document).ready(setupGermanAddressAutocompleteEvents);
///
///Added by Toolset/Minesh: https://toolset.com/forums/topic/search-by-location-using-toolset-maps-no-longer-working-correctly/?paged=2#post-2833156
///
jQuery(document).ready(function($){
let activeToolsetAjax = null;
$(document).ajaxSend(function(event, jqXHR, settings) {
// Only target Toolset search AJAX calls
if (settings.data && settings.data.indexOf('action=wpv_get_view_query_results') !== -1) {
// If a Toolset request is already running, cancel this new one (the duplicate)
if (activeToolsetAjax && activeToolsetAjax.readyState !== 4) {
// console.log('Blocked duplicate Toolset AJAX request');
jqXHR.abort(); // cancel the second request
return;
}
// Otherwise, mark this as the active one
activeToolsetAjax = jqXHR;
// When it finishes, clear the tracker
jqXHR.always(function() {
activeToolsetAjax = null;
});
}
});
});
Pleae note that this code is to fix the address search box issue and once you confnirm its working I will split the ticket with your add-on issue.