• Resolved joelmellin

    (@joelmellin)


    Hi!

    A few months I got this code from you:

    add_action( 'wp_footer', function() { ?>
    	<script type="text/javascript">
    		jQuery( document ).on( 'fibosearch/close', () => {
    			window.location.;
    		});
    	</script>
    <?php }, 9999 );
    
    

    However this is not working well anymore. When I write something in the searchfield and press enter, the page refreshes and clears the search field instead of showing the search result.

    We got the code from the beginning so that the page will refresh if someone cleares the search field so that they could see all products again. But not it seems like it is refreshing even when the search field is not cleared.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @joelmellin,

    Please replace the previous code snippet with this new improved one:

    add_action( 'wp_footer', function() { ?>
    	<script type="text/javascript">
    		jQuery(document).ready(function() {
    			var typingTimer;
    
    			function checkInputAndAction() {
    				var inputValue = jQuery('#dgwt-wcas-search-input-2').val();
    				if (inputValue.length == 0) {
    					window.location.;
    				}
    			}
    
    			jQuery('#dgwt-wcas-search-input-2').on('input', function() {
    				clearTimeout(typingTimer);
    				typingTimer = setTimeout(checkInputAndAction, 500);
    			});
    		});
    	</script>
    <?php }, 9999 );

    Regards,
    Kris

    Thread Starter joelmellin

    (@joelmellin)

    Thanks! It seems to work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Refresh the page’ is closed to new replies.