Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #647394

    Finlando
    Participant

    Hello,

    After You type something in the searchfield but do not hit enter or do not select something from the autocomplete dropdown, I want to make the typed in text disapear, when klicking away from the search box (when klicking somewhere else on the site). Do You have a Tip for custom CSS or Java?

    Thanks a lot in advance.

    #647395

    Finlando
    Participant
    This reply has been marked as private.
    #647401

    Thai
    Moderator

    Hi There,

    Try adding following code under Customize > Custom > Javascript:

    jQuery(document).ready(function($) {
    	$("#st-search-input input").focusout(function(event) {
    		$(this).val("");
    	});
    });

    Hope it helps.

    #647403

    Finlando
    Participant

    Hello,

    Thanks a lot. Looks great! I really appreciate Your help.., but when clicking back in the search box, the autocomlete dropdown appears like there is still the same text inside. (You can try the search with “non”, to see the autocomlete dropdown)

    Is it possible to clear out the search field on .focusout?

    Cheers!

    #647415

    Thai
    Moderator

    Hi There,

    Please update the previous code a bit:

    jQuery(document).ready(function($) {
    	$("#st-search-input input").focusout(function(event) {
    		$(this).val("");
    		$(".swiftype-widget .autocomplete ul").empty();
    	});
    });

    Hope it helps 🙂

    #647419

    Finlando
    Participant

    Hi,

    Works like a charm! Thanks a lot.

    Cheers!

    #647421

    Thai
    Moderator

    You’re most welcome 🙂

    If you need anything else, please let us know.

    #647422

    Finlando
    Participant
    This reply has been marked as private.
    #647426

    Christopher
    Moderator

    Hi there,

    I recommend you to start with W3scools tutorials.

    Hope it helps.

    #662339

    Finlando
    Participant

    Hi,

    Sorry for bothering again. There is a little bug with the searchbar and the following code..:

    jQuery(document).ready(function($) {
    	$("#st-search-input input").focusout(function(event) {
    		$(this).val("");
    		$(".swiftype-widget .autocomplete ul").empty();
    	});
    });

    with this code assigned, You can’t select a result from the autocomlete dropdown list of the searchbar. (You can try it by typing in “non”)

    Can I somehow exclude this function when the user clicks in the autocomplete dropdown?

    Thanks.

    #662401

    Finlando
    Participant
    This reply has been marked as private.
    #662497

    Zeshan
    Member

    Hi there,

    Thanks for updating the thread!

    This could technically be possible with more in depth JS customization, but would regretfully fall outside the scope of support we can provide. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.

    Thanks for understanding.