Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support button to open/close results #141

Open
tmaier opened this issue Aug 7, 2023 · 2 comments
Open

Support button to open/close results #141

tmaier opened this issue Aug 7, 2023 · 2 comments

Comments

@tmaier
Copy link

tmaier commented Aug 7, 2023

Suppose you have such a combobox:

image

When one closes the combobox, one should be able to re-open it by clicking on the button (to the right).

Please add a toggleResults or showResults method, one could bind to the button.

@Lxxrxns
Copy link

Lxxrxns commented Apr 20, 2024

Yes, we need this method. It seems it doesn't even let me trigger showing the results with a .trigger("change") or keyup or whatever ...

@Lxxrxns
Copy link

Lxxrxns commented Apr 21, 2024

Update:

I added a single line of code to the autocomplete.js file to allow external (programmatic) triggering of the search.

Add this to the connect() function in autocomplete.js:

document.addEventListener("doSearch", this.onInputChange);

Then, in your website/app, you can trigger this event manually by doing:

const event = new Event("doSearch"); 
document.dispatchEvent(event); 

For example, if you want to trigger the search using a button press, in jQuery you could do:

$('#yourButton').click(function(e){
  const event = new Event("doSearch"); 
  document.dispatchEvent(event);    
});

And voila, pressing the button with id="yourButton" will trigger the search.

It's a bit hacky, but I'm not a javascript expert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants