-
Notifications
You must be signed in to change notification settings - Fork 610
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 can I act on a selection as soon as it is made, without requiring a button click? #16909
Comments
How do I add a label to this issue? |
You can use The |
Thanks, I really appreciate the reply. I'm having difficulty following what is going on there with the jquery and the bind. Here is the code I have that is not working: input = document.getElementById("districtPicker1"); The "oninput" event gets fired whenever a character is typed into the input field. Do I need to do something analogous to Thanks again. |
It looks like you need something like this: input = document.getElementById("districtPicker1");
var awesomplete = new Awesomplete(input);
awesomplete.list = districtNameArray;
Awesomplete.$.bind(input, { "awesomplete-selectcomplete": selectDistrictWithPicker }); The function selectDistrictWithPicker(evt) {
console.log(evt.text);
} |
Fantastic, that did the trick. Thank you! I still don't quite follow how it's working, but with the explanation you provided and a bit of time I should be able to get there. |
Please note that Awesomplete does not use jQuery. JQuery is not the only thing that can define a $ function. |
This actually worked perflectly for my case. Thanks a lot! |
I'm trying to do something which seems like it should be very straightforward, but just can't figure it out. I'm pretty new to JavaScript, so I may be missing something obvious. I would like to act on the newly selected value as soon as it is chosen (e.g. with a click or Enter), without requiring a button press. But I can't figure out which event to use. "oninput" fires whenever anything is typed in the input field, but not when the input field value is changed by picking an option from the list of suggestions. The "awesomplete-select" event seems like it should work, but it doesn't. I suspect that's because of event.preventDefault(), but if so I don't know how to override that and make the event fire. Thanks for any assistance anyone can offer!
The text was updated successfully, but these errors were encountered: