See: http://www.airbnb.com/
In the search bar, start typing "san f" (no quotes, all lowercase), then hit Return (or Enter). "San Francisco" is autocompleted. This is good!
Now clear the search field and start over. type "San F" and boom - "San Francisco" is autocompleted as soon as you hit Shift. This is not expected.
This happens in FF & Safari, but is untested elsewhere. I've looked through the jQuery Autocomplete Source Code and everything looks normal.
Has anyone experienced this before?
Try Search option in autocomplete as follow:
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags,
search: function( event, ui ) {
if(event.which == 16 || event.which == 17 )
event.preventDefault();
}
});
To get around this issue:
To the KEY object add:
SHIFT: 16,
CTRL: 17,
ALT: 18
And to the very top of the onChange function add:
if ( jQuery.inArray(lastKeyPressCode, [KEY.SHIFT, KEY.CTRL,
KEY.ALT]) !== -1 )
return;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With