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

Reply To: Reset button in settings section does not reset the settings!

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Reset button in settings section does not reset the settings! Reply To: Reset button in settings section does not reset the settings!

#22434
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

The ‘do nothing’ will reset the filters to the initial values (as on page load), but then does not trigger the search bar, right now you have it that way. You should leave it as it is right now, and also add a custom code.

Add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

add_action('wp_footer', 'asp_close_on_reset');
function asp_close_on_reset() {
  ?>
  <script>
  jQuery(function($){
    $.xhrPool = [];  
    $.xhrPool.abortAll = function() {
        $(this).each(function(i, jqXHR) {   //  cycle through list of recorded connection
            jqXHR.abort();  //  aborts connection
            $.xhrPool.splice(i, 1); //  removes from list by index
        });
    }
    $.ajaxSetup({
        beforeSend: function(jqXHR) { $.xhrPool.push(jqXHR); }, //  annd connection to list
        complete: function(jqXHR) {
            var i = $.xhrPool.indexOf(jqXHR);   //  get index for current connection completed
            if (i > -1) $.xhrPool.splice(i, 1); //  removes from list by index
        }
    });
    $('.asp_sb').on('click', '.asp_reset_btn', function(){
      $('.proclose').click();
      $('.proloading').css('display', 'none');
      $.xhrPool.abortAll();
    });
  });
  </script>
  <?php
}

This is not the best solution, but it should be okay.