在jQuery UI的自动完成功能的jQuery捕获点击事件 [英] Jquery catching click event on jquery ui autocomplete
问题描述
我一直在试图最近想出解决办法,但我不能
i have been trying to figure this out lately but i can't
问题是,我有一个输入
字段类型文本
,我需要获得当前的输入数据当来自自动完成的值被选择。的注意我用jQuery用户界面自动完成。的
the problem is that i have an input
field with type text
that i need to get the current input data when the values from the autocomplete are selected. Note i am using jQuery UI autocomplete.
我能赶上 KEYUP
事件,但是当用户在自动完成值使用的点击。 jQuery的不火的变更
事件处理程序,我试图用每一个事件处理程序,但也无济于事。
i can catch the keyup
event but when a user uses clicks on the autocomplete values. jQuery does not fire the change
event handler, i tried using every event handler there is but to no avail.
我认为它不能赶上元素的DOM操作基础?我不确定。这里是一个
小提琴
i think it cannot catch a DOM based manipulation of an element? i'm not sure. here is a fiddle
推荐答案
筛选 http://jsfiddle.net / PUpRr /
选择
选项应该做的伎俩。
的选项/事件/方法API文档的: http://api.jqueryui.com/autocomplete/
希望这符合需求的:)
样品code
$("#to").autocomplete({
source: function (request, response) {
var friendsArray = [];
friendsArray = [{
"id": 1,
"name": "hulk",
"value": "hulk"
}, {
"id": 2,
"name": "ironman",
"value": "ironman"
}, {
"id": 3,
"name": "Foobar",
"value": "Foobar"
}];
response(friendsArray);
return;
},
select: function (e, ui) {
alert("selected!");
},
change: function (e, ui) {
alert("changed!");
}
});
这篇关于在jQuery UI的自动完成功能的jQuery捕获点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!