[英]jQuery autocomplete 1.1: Show All Data on focus
如何使此擴展顯示焦點上的所有數據? 我試圖將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];
}
});
您需要將焦點事件綁定到輸入並作為結果調用jQuery UI方法。 看看這個js小提琴的例子
我添加了以下代碼:
$('#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", "");
});
我最近有同樣的問題,由於這個插件已經過時(並且已棄用),因此該版本的文檔很少。
這對我有用:
var __n_clicks = 0;
$("#autocomplete_input").autocomplete(data, {
minChars: 0,
...
}).on('click', function(event) {
if(__n_clicks < 1){
__n_clicks++;
$(this).click();
}else {
__n_clicks = 0;
}
});
執行“dblclick”也不起作用,它必須是2次點擊。
如果你想使用這個插件的一些組合框試試這個:
$('.lookup').on('click', function(event) { var str =$(this).attr('id'); $('#'+str.slice(1)).focus().click().click(); });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.