Searchbar user focus trigger search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Searchbar user focus trigger search

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #33818


    I had a few emails back and forth with Ernest about what I can achieve with this plugin and I have since purchased a license.

    I am trying to emulate the search bar seen at merchbar dot com.
    The plugin is able to do what I need with a normal search via text.

    But I am trying to emulate the functionality where the user simply focuses the search bar without having to type text. It gives a preview of certain taxonomy / item.

    Ernest mentioned setting up a javascript trigger to initialize a search when the user focuses the search box.
    Would be great if you could help.

    I do have access to a public server which we can use, I just need to move my test environment there first.


    You must be logged in to view attached files.
    Ernest Marcinko
    Ernest Marcinko


    This custom code should help you triggering the search whenever the input is focused:

    add_action('wp_footer', 'wp_footer_asp_custom_script', 9999);
    function wp_footer_asp_custom_script() {
    			el.addEventListener('focus', function(){
    				el.dispatchEvent(new Event('input'));

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    This code will trigger the search initially, whenever the user clicks on the input field.

    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.