jQuery 自动完成触发更改事件 [英] jQuery AutoComplete Trigger Change Event
本文介绍了jQuery 自动完成触发更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以编程方式触发 jQuery UI 的 AutoComplete 更改事件处理程序?
How do you trigger jQuery UI's AutoComplete change event handler programmatically?
连接
$("#CompanyList").autocomplete({
source: context.companies,
change: handleCompanyChanged
});
迄今为止的各种尝试
$("#CompanyList").change();
$("#CompanyList").trigger("change");
$("#CompanyList").triggerHandler("change");
根据其他答案它应该工作:
当我通过浏览器手动与自动完成输入交互时,更改事件按预期触发;但是我想在某些情况下以编程方式触发更改事件.
The change event fires as expected when I manually interact with the AutoComplete input via browser; however I would like to programmatically trigger the change event in some cases.
我错过了什么?
推荐答案
给你.这有点乱,但很管用.
Here you go. It's a little messy but it works.
$(function () {
var companyList = $("#CompanyList").autocomplete({
change: function() {
alert('changed');
}
});
companyList.autocomplete('option','change').call(companyList);
});
这篇关于jQuery 自动完成触发更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文