This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

X not “resetting” query +GeneratePress

X not “resetting” query +GeneratePress

Home Forums Product Support Forums Ajax Search Pro for WordPress Support X not “resetting” query +GeneratePress

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #57735
    opusuno_qeTzopusuno_qeTz
    Participant

    Hi 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.

    #57739
    opusuno_qeTzopusuno_qeTz
    Participant

    I 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.

    #57740
    opusuno_qeTzopusuno_qeTz
    Participant

    Here 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>

    #57741
    opusuno_qeTzopusuno_qeTz
    Participant

    This seems to have fixed it. Good for your notes I hope.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.