Pre-story: I am using Algolia search to search on my website.If the user start typing in the input field the results will start appearing on the screen.
End goal: close the filters (toggle functionality) by default.
Issues: when the user start typing in the input the url change and the filters stay open.
- If I apply the code in the console after the user finishes with typing I can see the button being close.
- If I apply the jQuery codes bellow and while I am typing the filters stay closed, but again once the user stops typing the filters open again.
- Once I finish with typing (input looses focus) the filters open again.
My approach:
First
$("input#dropdown_search").on('input',function(e){ $("b- utton.button.filters__button").click(); });
Second
$('input#dropdown_search').keyup(function() { $("button.button.filters__button").click(); });
Third
$('input#dropdown_search').on('inputchange', function() { $("button.button.filters__button").click(); });
Fourth
$("input#dropdown_search").on('change keyup paste', function () { ApplyFilter(); }); function ApplyFilter() { $("button.button.filters__button").click(); }
It seems that they don't reach the end goal where they keep the filter hidden even after the user stops typing.
Can you please help?