admin管理员组文章数量:1419202
I want jQuery Autoplete on textbox key down event
I have tried below code, but it is not working.
$("#txtName").keyDown({
$("#txtName").autoplete({
source: '@Url.Action("GetAllName", "Home")',
select: function (event, ui) {
$("#txtName").val(ui.item.value);
return false;
}
});
});
I want jQuery Autoplete on textbox key down event
I have tried below code, but it is not working.
$("#txtName").keyDown({
$("#txtName").autoplete({
source: '@Url.Action("GetAllName", "Home")',
select: function (event, ui) {
$("#txtName").val(ui.item.value);
return false;
}
});
});
Share
Improve this question
edited Sep 15, 2014 at 11:09
Ashley Medway
7,3097 gold badges53 silver badges73 bronze badges
asked Sep 15, 2014 at 11:05
User5590User5590
1,4356 gold badges28 silver badges68 bronze badges
6
-
i think
$("#txtName").autoplete()
is sufficient no need for keyDown – Sandip Pingle Commented Sep 15, 2014 at 11:08 - What does the MVC action look like? – Ashley Medway Commented Sep 15, 2014 at 11:08
-
You just want it to begin searching on the first keystroke? Try using
minLength: 1
. – DevlshOne Commented Sep 15, 2014 at 11:08 - @SandipPingle $("#txtName").autoplete() is working. But i want functionality like, when i first click on textbox and press key down, then all the results should e – User5590 Commented Sep 15, 2014 at 11:10
- @AshleyMedway Here i am using Url.Action. so Home is my controller and GetAllName is ActionName – User5590 Commented Sep 15, 2014 at 11:11
2 Answers
Reset to default 4You do not need the keyDown
event otherwise you are rebinding the autoplete on every keydown.
$("#txtName").autoplete({
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./a/4604300/1398425
If you just want it to begin searching on the first keystroke, try using minLength: 1
:
$("#txtName").autoplete({
source: '@Url.Action("GetAllName", "Home")',
minLength: 1,
select: function (event, ui) {
$("#txtName").val(ui.item.value);
return false;
}
});
本文标签: javascriptSet jQuery Autocomplete on Textbox KeyDown EventStack Overflow
版权声明:本文标题:javascript - Set jQuery Autocomplete on Textbox KeyDown Event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745292765a2651896.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论