admin管理员组文章数量:1022670
When using keyup keydown to select option from autoplete list textbox is showing value. But incase of selection from mouse it is working properly. JsFiddle -
$("#promoteActionTextBox").autoplete({
source: actionNames,
minLength: 0,
select: function (event, ui) {
event.preventDefault();
$(this).val(ui.item.label);
$('#promoteActionError').hide();
$(this).attr('actionId', ui.item.value);
},
change: function (event, ui) {
if (!ui.item) {
$(this).val('');
}
else {
$('#promoteActionError').hide();
$(this).val(ui.item.label);
$(this).attr('actionId', ui.item.value);
}
}
}).focus(function (event, ui) {
event.preventDefault();
$('#promoteActionTextBox').autoplete("search");
this.value = ui.item.label;
});
When using keyup keydown to select option from autoplete list textbox is showing value. But incase of selection from mouse it is working properly. JsFiddle - http://jsfiddle/0c21r1pe/1
$("#promoteActionTextBox").autoplete({
source: actionNames,
minLength: 0,
select: function (event, ui) {
event.preventDefault();
$(this).val(ui.item.label);
$('#promoteActionError').hide();
$(this).attr('actionId', ui.item.value);
},
change: function (event, ui) {
if (!ui.item) {
$(this).val('');
}
else {
$('#promoteActionError').hide();
$(this).val(ui.item.label);
$(this).attr('actionId', ui.item.value);
}
}
}).focus(function (event, ui) {
event.preventDefault();
$('#promoteActionTextBox').autoplete("search");
this.value = ui.item.label;
});
Share
Improve this question
edited Jan 16, 2015 at 7:23
Manjay_TBAG
asked Jan 16, 2015 at 6:25
Manjay_TBAGManjay_TBAG
2,2553 gold badges24 silver badges46 bronze badges
2
- @Innovarion - My jsfiffle link - jsfiddle/0c21r1pe/1 – Manjay_TBAG Commented Jan 16, 2015 at 7:15
- There is problem with value change it into something like avalue then it will work – Innovation Commented Jan 16, 2015 at 10:27
2 Answers
Reset to default 4change the object property name from value
to something else and it works
WORKING DEMO
UPDATE
How about THIS FIDDLE
I added a code which removes the event which is responsible for that effect.
create:function(){
$('.ui-autoplete').unbind('menufocus');
}
select: function(event, ui) {
event.preventDefault(); // Add on keyboard keyup, keydown is working well
$("#id_value").val(ui.item.value);
$("#id_label").val(ui.item.label);
},
focus: function( event, ui ) {
event.preventDefault(); // Add on keyboard keyup, keydown is working well
$("#id_value").val(ui.item.value);
$("#id_label").val(ui.item.label);
}
When using keyup keydown to select option from autoplete list textbox is showing value. But incase of selection from mouse it is working properly. JsFiddle -
$("#promoteActionTextBox").autoplete({
source: actionNames,
minLength: 0,
select: function (event, ui) {
event.preventDefault();
$(this).val(ui.item.label);
$('#promoteActionError').hide();
$(this).attr('actionId', ui.item.value);
},
change: function (event, ui) {
if (!ui.item) {
$(this).val('');
}
else {
$('#promoteActionError').hide();
$(this).val(ui.item.label);
$(this).attr('actionId', ui.item.value);
}
}
}).focus(function (event, ui) {
event.preventDefault();
$('#promoteActionTextBox').autoplete("search");
this.value = ui.item.label;
});
When using keyup keydown to select option from autoplete list textbox is showing value. But incase of selection from mouse it is working properly. JsFiddle - http://jsfiddle/0c21r1pe/1
$("#promoteActionTextBox").autoplete({
source: actionNames,
minLength: 0,
select: function (event, ui) {
event.preventDefault();
$(this).val(ui.item.label);
$('#promoteActionError').hide();
$(this).attr('actionId', ui.item.value);
},
change: function (event, ui) {
if (!ui.item) {
$(this).val('');
}
else {
$('#promoteActionError').hide();
$(this).val(ui.item.label);
$(this).attr('actionId', ui.item.value);
}
}
}).focus(function (event, ui) {
event.preventDefault();
$('#promoteActionTextBox').autoplete("search");
this.value = ui.item.label;
});
Share
Improve this question
edited Jan 16, 2015 at 7:23
Manjay_TBAG
asked Jan 16, 2015 at 6:25
Manjay_TBAGManjay_TBAG
2,2553 gold badges24 silver badges46 bronze badges
2
- @Innovarion - My jsfiffle link - jsfiddle/0c21r1pe/1 – Manjay_TBAG Commented Jan 16, 2015 at 7:15
- There is problem with value change it into something like avalue then it will work – Innovation Commented Jan 16, 2015 at 10:27
2 Answers
Reset to default 4change the object property name from value
to something else and it works
WORKING DEMO
UPDATE
How about THIS FIDDLE
I added a code which removes the event which is responsible for that effect.
create:function(){
$('.ui-autoplete').unbind('menufocus');
}
select: function(event, ui) {
event.preventDefault(); // Add on keyboard keyup, keydown is working well
$("#id_value").val(ui.item.value);
$("#id_label").val(ui.item.label);
},
focus: function( event, ui ) {
event.preventDefault(); // Add on keyboard keyup, keydown is working well
$("#id_value").val(ui.item.value);
$("#id_label").val(ui.item.label);
}
版权声明:本文标题:javascript - Jquery Ui AutoComplete is not working with keyupdown when used with label value - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745531351a2154764.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论