我想要一些关于如何为jquery autocomplete组合框设置事件处理程序的建议:
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) {
...
});
我已经试过了——按照下面的描述——但它不起作用。我从这个关闭的bug报告(dev.jqueryui.com/ticket/5891)了解到我“正在实例化一个组合框,然后尝试使用autocomplete设置选项”,但我不知道如何修复它。
$(document).ready(function() {
$("#comboInput").combobox();
$("#comboInput").autocomplete({
select: function(event, ui) {
alert("Value selected.");
}
});
});
有人能告诉我怎么做吗?感谢您的帮助!