如何制作this extension在焦点上显示所有数据?我试图将 minChars 更改为 0
但它仅在输入双击时显示。
$("#month").autocomplete(months, {
minChars: 0,
max: 12,
autoFill: true,
mustMatch: true,
matchContains: false,
scrollHeight: 220,
formatItem: function(data, i, total) {
// don't show the current month in the list of values (for whatever reason)
if ( data[0] == months[new Date().getMonth()] )
return false;
return data[0];
}
});
最佳答案
您需要将焦点事件绑定(bind)到输入并调用 jQuery UI 方法作为结果。看看this js fiddle for an example
我添加了以下代码:
$('#month').autocomplete({
// Your current code
}).on('focus', function(event) {
var self = this;
$(self).autocomplete( "search", this.value);;
});
传递给 search
方法的值是自动完成将查找的内容。
如何搜索焦点上的所有值
如果您想要所有可用的下拉菜单,请将其保留为“”,但将 minLength : 0
添加到选项对象。
$('#month').autocomplete({
minLength : 0
}).on('focus', function(event) {
$(this).autocomplete("search", "");
});
关于javascript - jQuery 自动完成 1.1 : Show All Data on focus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16874214/