您如何触发自动完成“选择" jQueryUI中手动事件? [英] How do you trigger autocomplete "select" event manually in jQueryUI?
本文介绍了您如何触发自动完成“选择" jQueryUI中手动事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jQueryUI自动完成功能,并且有一个映射到select事件的函数,例如:
I'm using jQueryUI autocomplete, and I have a function mapped to the select event, e.g.:
$("#someId").autocomplete({
source: someData,
select: function (event, ui) { ... },
focus: function (event, ui) { ... }
});
我有一个特殊情况:用户已将注意力集中在自动完成下拉列表中的一个项目上(但未选中该项目),我需要从其他功能手动触发select事件.这可能吗?如果可以,怎么办?
I have a special case: The user has focused on an item in the autocomplete drop-down (but not selected it) and I need to trigger the select event manually from a different function. Is this possible? If so, how?
推荐答案
以下是对我有用的东西:
Here's what worked for me:
$(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', {item:{value:$(this).val()}});
这篇关于您如何触发自动完成“选择" jQueryUI中手动事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文