【发布时间】:2011-04-11 23:09:36
【问题描述】:
我想要一些关于如何为 jQuery 自动完成组合框设置事件处理程序的建议:http://jqueryui.com/demos/autocomplete/#combobox。
jQuery 文档中的代码示例如下:
// Supply a callback function to handle the select event as an init option.
$( ".selector" ).autocomplete({
select: function(event, ui) { ... }
});
// Bind to the select event by type: autocompleteselect.
$( ".selector" ).bind( "autocompleteselect", function(event, ui) {
...
});
我已经尝试过 - 如下所述 - 但它不起作用。我从这个已关闭的错误报告 (dev.jqueryui.com/ticket/5891) 中了解到我正在“实例化一个组合框,然后尝试使用自动完成设置选项”,但我不明白如何修复它。
// Have: <select id="comboInput" name="comboInput"> ....
$(document).ready(function() {
$("#comboInput").combobox();
$("#comboInput").autocomplete({
select: function(event, ui) {
alert("Value selected.");
}
});
});
谁能告诉我如何使这项工作?感谢您的帮助!
【问题讨论】:
标签: jquery combobox autocomplete