I am using the following jquery ui autocomplete function. This is working perfectly with mouse but by keyboard, I am not able to select any value. Have a look at the code.
$("#"+textBoxId).autocomplete("../common
/autoSuggestValues.php?index="+index+"&
randValue="+Math.random(), {
selectFirst: false,
width:textBoxWidth,
minChars: 2,
autoFill: false,
scroll: true,
scrollHeight: 120,
formatItem: function (rowdata) {
var details = rowdata[0].split('@#@');
return details[0];
}
});
$('#'+textBoxId).result(function (event, data, formatted) {
var det = data[0].split("@#@");
if(det[0] != 'No Match Found') {
$('#'+textBoxId).val($.trim(det[0])).css('border','');
$('#'+hiddenId).val(det[1]);
processAutoSuggOptFunc(optionalFunction); //process the optional
function using the another built function "processAutoSuggOptFunc"
} else {
$('#'+textBoxId).val('');
$('#'+hiddenId).val('');
}
});
If autocomplete dropdown is open, Esc press shoult perform its default action only (closing dropdown and cancelling selection). How to check if autocomplete dropdown was opened ? It can check for any autocomplete box was opened in document body.
In the process of searching a specific value, the jQuery UI autocomplete selection feature provides the user with some string suggestions for the input area which effectively saves time. The autocomplete select action is triggered when the user selects one of the options from the pre-populated list.
The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try. The datasource is a simple JavaScript array, provided to the widget using the source-option. 1.
For me, providing the focus method made the solution:
searchField.autocomplete({
...
focus: function (event, ui) {
event.preventDefault();
jQuery(this).val(ui.item.suggestion);
},
... });
See also here: http://yuji.wordpress.com/2011/09/22/jquery-ui-autocomplete-focus-event-via-keyboard-clears-input-content/
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