Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Trouble resetting the search
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 2 years ago.
- AuthorPosts
- March 3, 2021 at 11:18 pm #31972
Hi there,
I’d like to know how we can properly reset a user search, when we type in a term and simply hit backspace, it does work, the list of terms is reset but when we click on the black cross to delete the term in one click, it doesn’t reset the list.
Link here: https://www.tti-online.com/glossary-2/
Thanks,
March 4, 2021 at 3:19 pm #31995Hi,
That button is only to clear the search phrase from the input field. However I might be able to suggest a custom code.
Try adding 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!
Best,add_action('wp_footer', 'asp_trigger_search_on_close'); function asp_trigger_search_on_close() { ?> <script> jQuery(function($){ $('.proclose svg').on('click touchend', function(e){ var $e = $(this).closest('.asp_w'); setTimeout(function(){ ASP.api($e.data('id'), $e.data('instance'), 'searchFor'); }, 250); }); }); </script> <?php }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 4, 2021 at 4:14 pm #32003Many thanks for that, it works well! The only problem is that it reverses the alphabetical order, any idea why?
Thanks,
March 4, 2021 at 4:20 pm #32005Well, because this triggers an actual search for an empty phrase, and if the ordering is set by relevance (default), then the items are shown by that order. To get the original state the page would have to be completely reloaded.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.