If mousing over your autocomplete results correctly updates the input box with the currently highlighted value, but doing so via keyboard doesn’t (leaves the input blank) no matter what you put in your focus function, you need to prevent the default behavior from triggering.
For whatever reason, the default behavior works for mouse hovers but not keyboard.
$("#faq_search").autocomplete({
source: "/faq/ajax/",
focus: function( event, ui ) {
event.preventDefault(); // without this: keyboard movements reset the input to ''
$(this).val(ui.item.question);
},
select: function( event, ui ) {
document.location.href = ui.item.url;
},
context: this
})
Thank you so much it worked perfectly! Saved me many hours of frustration I am sure. I just wish there was a way for the text to have a value when selected with arrows and auto filling the field. I was having a bit of a hard time debugging it. If you have any other tips on making it work better that would be great. Thanks for the perfect solution anyways 🙂
hi, i am using jquery.autocomplet.js plugin in my application and facing same problem as i can not use the up and down arrow keys for selecting results from autocomplete list. What can i do to solve the problem.
Thanks in advance
rahul
rahulmca.99@gmail.com
Thanks, this worked like a charm on a Dynamics CMR 2013 :D.
Thanks. I’ve been trying different configurations but I didn’t think about the event.preventDefault().
Thanks!!
Thank you so much. Domo arigato gozaimasu
Thanks Man
Thank you so much for sharing this!! Saved me countless hours.
Old post, but it seems to never get outdated! Thanks a lot, this gave me a terrible headache!
What is question in ui.item.question