Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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?

    Website Here

    Thank you in advance,

    Francisco

    #788250

    Hey Francisco,

    I am not sure about your question with the “close the ajax_search”. May you explain it better?

    Best regards,
    John Torvik

    #789294

    Sure, I just don’t know what to call it. Here is a picture of it Search Results
    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

    #789353

    Hi,

    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 Torvik

    #790149

    Thank you for your reply.

    Where should I paste this code?

    #791291

    Hi,

    You have to use the code at the functions.php file.
    Let us know if anything else

    Best regards,
    Basilis

    #800096

    Hi,

    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

    #800486

    Managed 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
    }
    #800574

    Hi 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

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