-
Notifications
You must be signed in to change notification settings - Fork 72
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
How to submit selected autocomplete suggestion? #10
Comments
Hi @chrisbartley and thank you. :) Regarding your second question, that will indeed be a workaround. You need to stop the automatic submit of the form and then act accordingly (i.e. submitting the form manually) like in this modified version of your fiddle. https://jsfiddle.net/f0m6bctr/9/ Let me know if it works. I will create another issue to investigate on this bug. |
Thanks for the quick reply and for looking in to this. I did try a little bit with the events and disabling auto submit of the form, but without success. But maybe I was just doing something dumb and/or overlooking something obvious. I'll have another look and provide an update here. Thanks! |
@chrisbartley here you'll find your example modified to submit the form intercepting the select event. https://jsfiddle.net/6a48wdq1/1/ Let me know :) |
That does work for submitting selected popup item, thank you. However, I think maybe the trouble I had before was also allowing the user to input and submit other text. I'm using this plugin for a search form, so I need to be able to allow the user to type anything they want in the input and either choose something from the autocomplete popup or simply hit ENTER and have it submit the form and search on what they typed. I can't remember the exact problem I was having when I tried this before, but I think I had a function being called onsubmit of the form, but the |
@chrisbartley that is what i call free value, you can intrcept it and submit form with the |
Thanks. I fiddled around with https://jsfiddle.net/chrisbartley/5rjqyvnk/9/ If you type in something that won't autocomplete, e.g. |
Hi @chrisbartley This is your test case to test it out. :) https://raw.githack.com/xcash/bootstrap-autocomplete/master/dist/latest/testdata/test-issue-10.html |
First, I love this plugin, thank you! It's working great for me, except I haven't been able to figure out how to capture the selected item in the list of autocomplete suggestions for form submission. I'm using Bootstrap 4.1 and jQuery 3.3.1. Here's a fiddle:
https://jsfiddle.net/chrisbartley/t192eb6r/19/
If you start typing "goo" in the input, you'll get the 4 autocomplete suggestions. Then hit the down arrow to select any of the items in the popup, then hit RETURN to select it and submit the form. But, as you see in the window that opens, the form submits to https://example.com/?q=goo. How do I get it to submit the selected item in the popup menu instead of only what was actually typed ("goo" in this case)?
Perhaps more to the point, I'm not aware of an event I can listen for which would allow me to determine selected autocomplete item. Does one exist?
The text was updated successfully, but these errors were encountered: