X not “resetting” query +GeneratePress
Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › X not “resetting” query +GeneratePress
- This topic has 3 replies, 1 voice, and was last updated 14 minutes ago by
opusuno_qeTz.
-
AuthorPosts
-
July 27, 2026 at 10:06 pm #57735
opusuno_qeTz
ParticipantHi Ernest,
I added a search field to a GeneratePress Query and it works. But when i hit the “X” it’s not resetting… Any ideas? Added some screenshots. 1st is default Query. 2nd is using a suggested search. Works. 3rd after hitting the X .. Query not updating.
July 28, 2026 at 12:22 am #57739opusuno_qeTz
ParticipantI found the setting that clears the query back to default.
However, I am trying to use this in combination with WPGridBuilder facets.
The ASP search and the X is doing something to detach WPGB ability to run a query.
I can select from a menu, and reset the filters, but the query is not working. This AFTER using ASP.
When I use WPGB BEFORE ASP it works fine. Put another way — after searching with ASP WPGB stops working on the page.
I tried the Gemini / Claude route to try and fix it but nothing is working. Any help is appreciated. I need the ability to filter results.
July 28, 2026 at 12:23 am #57740opusuno_qeTz
ParticipantHere is the JS Gemini proposed. It does not fix it.
<script type=”text/javascript”>
window.addEventListener(‘load’, function() {
// 1. Ensure both Ajax Search Pro and WP Grid Builder global objects exist
if (typeof WPD === ‘undefined’ || typeof WP_Grid_Builder === ‘undefined’) return;
// 2. Safely hook into Ajax Search Pro’s global layout state routine
WPD.interval(‘asp_init’, function() {
// This targets all active ASP search instances initialized on the screen
jQuery(document).on(‘asp_search_end asp_reset’, function(event, id, instance) {
// 3. Look for the active string value of the input box
var currentSearchString = jQuery(‘.asp_main_container input.orig’).val();
// If the search string is completely empty (meaning the ‘X’ was hit or text cleared)
if (!currentSearchString || currentSearchString.trim() === ”) {
// Clear out the query history from the browser URL address bar seamlessly
if (window.history && window.history.replaceState) {
var cleanUrl = window.location.protocol + “//” + window.location.host + window.location.pathname;
window.history.replaceState({ path: cleanUrl }, ”, cleanUrl);
}
// 4. Force WP Grid Builder to dump its broken memory and rebuild DOM hooks
if (typeof WP_Grid_Builder.destroy === ‘function’) {
WP_Grid_Builder.destroy();
}
// Give the browser 100ms to settle the markup before rebinding dropdowns
setTimeout(function() {
if (typeof WP_Grid_Builder.render === ‘function’) {
WP_Grid_Builder.render();
}
var activeGrids = WP_Grid_Builder.getGrids();
if (activeGrids) {
Object.values(activeGrids).forEach(function(gridInstance) {
// Erase stuck query params inside the individual grid state blocks
if (gridInstance.params) {
gridInstance.params = {};
}
if (typeof gridInstance.init === ‘function’) gridInstance.init();
if (typeof gridInstance.refresh === ‘function’) gridInstance.refresh();
});
}
}, 100);
}
});
}, 10);
});
</script>
July 28, 2026 at 12:58 am #57741opusuno_qeTz
ParticipantThis seems to have fixed it. Good for your notes I hope.
-
AuthorPosts
- You must be logged in to reply to this topic.