3

この拡張機能ですべてのデータをフォーカスして表示するにはどうすればよいですか?. 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];
        }
    });
4

4 に答える 4

10

フォーカス イベントを入力にバインドし、結果として 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", "");
});
于 2013-06-01T15:35:23.670 に答える
0

このプラグインでいくつかのコンボボックスが必要な場合は、これを試してください:

$('.lookup').on('click', function(event) {
var str =$(this).attr('id');
$('#'+str.slice(1)).focus().click().click();
});

于 2016-11-23T09:08:03.667 に答える