Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  61] [ 6]  / answers: 1 / hits: 6532  / 10 Years ago, mon, september 15, 2014, 12:00:00

I want jQuery Autocomplete on textbox key down event



I have tried below code, but it is not working.



$(#txtName).keyDown({
$(#txtName).autocomplete({
source: '@Url.Action(GetAllName, Home)',
select: function (event, ui) {
$(#txtName).val(ui.item.value);
return false;
}
});
});

More From » jquery

 Answers
6

You do not need the keyDown event otherwise you are rebinding the autocomplete on every keydown.



$(#txtName).autocomplete({
source: '@Url.Action(GetAllName, Home)',
select: function (event, ui) {
$(#txtName).val(ui.item.value);
return false;
}
});


To show all results when one character is entered add minLength: 1



If what you want is to have all the items displayed when the textbox has focus then this is what you are looking for: https://stackoverflow.com/a/4604300/1398425


[#42504] Saturday, September 13, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lucillemariselal

Total Points: 108
Total Questions: 97
Total Answers: 119

Location: Thailand
Member since Thu, May 6, 2021
3 Years ago
;