在jquery自动完成模糊函数中获取所选的值 [英] Get the selected value in jquery autocomplete on blur function
问题描述
我想要有自动完成功能,当有模糊事件时,文本框应该填充值列表作为第一个项目。
我希望具有与此链接中实施的功能相同的
这里是一个类似的问题。
http://stackoverflow.com/a/15466735/1670643
I want to have auto complete functionality, where the text-box should get populated with the value list as a first item when there is an blur event.
I would like to have the functionality same as implemented in this link link
I have the code below, which populates on tab and enter key, but dont know how to achieve same functionality on blur event.
$( "#statelist" ).autocomplete({
autoFocus: true,
source: states,
select: function (event, ui) {
stateid = (ui.item.lable);
$("#stateid").val(stateid);
}
});
EDIT :- user enters a text lets us say type "che" and without pressing tab or enter key, user moves his control to next textbox, in this scenario I want the first list item to populated automatically in the textbox.
You can send a enter key on blur event.
$( "#statelist" ).blur(function(){
var keyEvent = $.Event("keydown");
keyEvent.keyCode = $.ui.keyCode.ENTER;
$(this).trigger(keyEvent);
}).autocomplete({
autoFocus: true,
source: states,
// ...
});
Here is the fiddle: http://jsfiddle.net/trSdL/4/
And here is a similar question. http://stackoverflow.com/a/15466735/1670643
这篇关于在jquery自动完成模糊函数中获取所选的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!