-
AuthorPosts
-
October 31, 2015 at 6:50 am #647394
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.
October 31, 2015 at 6:51 am #647395This reply has been marked as private.October 31, 2015 at 7:01 am #647401Hi 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.
October 31, 2015 at 7:12 am #647403Hello,
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!
October 31, 2015 at 7:21 am #647415Hi 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 🙂
October 31, 2015 at 7:39 am #647419Hi,
Works like a charm! Thanks a lot.
Cheers!
October 31, 2015 at 7:43 am #647421You’re most welcome 🙂
If you need anything else, please let us know.
October 31, 2015 at 7:43 am #647422This reply has been marked as private.October 31, 2015 at 7:47 am #647426November 12, 2015 at 5:20 am #662339Hi,
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.
November 12, 2015 at 6:39 am #662401This reply has been marked as private.November 12, 2015 at 8:06 am #662497Hi 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.
-
AuthorPosts