Tagged: search form
-
AuthorPosts
-
May 4, 2017 at 11:57 am #787731
Hi,
Is there a way to close the ajax_search_response on the header of this website when clicking outside or elsewhere on the website?
Thank you in advance,
Francisco
May 5, 2017 at 8:27 am #788250Hey Francisco,
I am not sure about your question with the “close the ajax_search”. May you explain it better?
Best regards,
John TorvikMay 8, 2017 at 4:49 am #789294Sure, I just don’t know what to call it. Here is a picture of it
As you start typing this window pops down but I want to be able to close it If I click elsewhere on the website.Thanks,
Francisco- This reply was modified 7 years, 6 months ago by Francisco Correia.
May 8, 2017 at 9:21 am #789353Hi,
The easier way is hiding this box after a certain time using this code:
function add_custom_script(){ ?> $(window).load(function(){ setTimeout(function(){ $('.ajax_not_found').fadeOut() }, 5000); });
But you can request it here: http://kriesi.at/contact/customization
Best regards,
John TorvikMay 9, 2017 at 11:22 am #790149Thank you for your reply.
Where should I paste this code?
May 10, 2017 at 7:16 pm #791291Hi,
You have to use the code at the functions.php file.
Let us know if anything elseBest regards,
BasilisMay 26, 2017 at 11:59 am #800096Hi,
I managed to put this code together which does close the search results after a click of the mouse.
add_action('wp_footer', 'close_search_on_click'); function close_search_on_click(){ ?> <script type="text/javascript"> jQuery(document).on('click',function(){ jQuery(".ajax_search_response").hide('slow'); }); jQuery(".ajax_search_response").on('click',function(e){ e.stopPropagation(); }); </script> <?php }
The downside is that after the search results close, if I retype something else on the search bar, I don’t get anymore search results. Could you help me with the code that will refresh that dropdown after typing?
Thanks
May 27, 2017 at 5:08 am #800486Managed to fix it by adding another function after the one mentioned on the previous post. Not sure if this is the most efficient fix but it works. I leave the code below for anyone that’s looking for the same.
add_action('wp_footer', 'restore_search_on_type'); function restore_search_on_type(){ ?> <script type="text/javascript"> jQuery("#s").on('keyup',function(){ jQuery(".ajax_search_response").show(); }); </script> <?php }
May 27, 2017 at 5:22 pm #800574Hi Francisco,
Glad you got it working for you! And thank you for sharing :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.