admin管理员组文章数量:1418037
I want to show the value of the autoplete suggesion on textbox only when the user is selecting the suggession. I tried
$("#trainerNameAutoComplete").autoplete({
source:"serverpage.php?id="+1,
minLength:1,
focus: function( event, ui ){
$("#trainerNameAutoComplete").val('');
},
keypress: function(event,ui){
if ((event.which == 38||event.Keycode ==38) || (event.which == 40||event.Keycode ==40)) {
console.log("key down");
$("#trainerNameAutoComplete").val('');
}
},
select:function(event,ui){
somefunction();
}
});
but the value is cleared in textbox when I hover the mouse over the suggestion but not when I press up and down arrow keys.
I want to show the value of the autoplete suggesion on textbox only when the user is selecting the suggession. I tried
$("#trainerNameAutoComplete").autoplete({
source:"serverpage.php?id="+1,
minLength:1,
focus: function( event, ui ){
$("#trainerNameAutoComplete").val('');
},
keypress: function(event,ui){
if ((event.which == 38||event.Keycode ==38) || (event.which == 40||event.Keycode ==40)) {
console.log("key down");
$("#trainerNameAutoComplete").val('');
}
},
select:function(event,ui){
somefunction();
}
});
but the value is cleared in textbox when I hover the mouse over the suggestion but not when I press up and down arrow keys.
Share Improve this question edited Aug 31, 2016 at 17:02 Mark Schultheiss 34.2k12 gold badges72 silver badges113 bronze badges asked Feb 28, 2013 at 14:18 AshwinAshwin 4553 gold badges7 silver badges15 bronze badges1 Answer
Reset to default 1 keydown: function(event,ui){
event.preventDefault();
if (event.Keycode ==38||event.Keycode ==40) {
console.log("key down");
$("#trainerNameAutoComplete").val('');
}
},
try this..instead of your keypress event
本文标签: javascriptkeypress event in autocomplete jquery uiStack Overflow
版权声明:本文标题:javascript - keypress event in autocomplete jquery ui - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745277966a2651290.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论