I use jquery autocomplete to search in a xml file.
The autocomplete function works fine. However, when I click on an element item of autocomplete menu result , the value put inside the input search box is not visible. Because there are a lot's of blank spaces (tab) that are added in the input box.
I really don't understand where it comes from (this blank spaces).
I made a fiddle, however on this fiddle the value is correctly place inside the input box...they aren't this blank space: http://jsfiddle.net/8zJkS/5/
script :
$("input#search").autocomplete({
minLength: 3,
source: myArr,
response: function(event, ui) {
if (ui.content.length === 0) {
$("#noMatches").show();
} else {
$("#noMatches").hide();
}
},
focus: function (event, ui) {
$('input#search').focus();
return false;
},
select: function (event, ui) {
$("input#search").val(ui.item.value);
return false;
}
});
By the way, I also search the way to have the hover effect also with keyboard. I have also some text that appear when i search and I don't know how to remove it.
It seems that jquery autocomplete documentation is very poor.
Sorry for my English, I'm french.
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.
You can just use var value = $("#Ac_Transporteur"). val(); to get the entered value in the Autocomplete field.
Syntax: $("TagId"). autocomplete({ source : itemList // List of Words. })
Enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering.
I solved my problem with this :
select: function(event, ui){
if (ui.item && ui.item.value){
titleinput = ui.item.value;
ui.item.value= $.trim(titleinput);
}
}
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