0

オートコンプリート機能にブートストラップの先行入力を使用しています。ユーザーが最初の文字を入力するのを待つのではなく、入力がアクティブになったときに(マウスクリックまたは入力へのタブで)結果を返すために先行入力が必要です。タイプダウンのようなものです。

<input id="input01" class="input-medium" type="text" data-provide="typeahead" placeholder="TypeAhead…" autocomplete="off">


$(document).ready(function($) {
    // Workaround for bug in mouse item selection
    $.fn.typeahead.Constructor.prototype.blur = function() {
        var that = this;
        setTimeout(function () { that.hide(); }, 250);
    };

    $('#input01').typeahead({
        source: function(query, process) {
            return ["hello","world", "awesome"];
        }
    });
});
4

2 に答える 2

2

私は長い間そのプラグインを使用していませんが、ルックアップ (または現在のメソッド) を手動で呼び出してみてください。

このようなもの:

$(document).ready(function($) {
  var $input = $('#input01');

  $input.typeahead({
    source: function(query, process) {
      return ["hello","world", "awesome"];
    }
  });

  $input.on('focus', function() {
    $input.typeahead.lookup();
  });
});
于 2013-06-13T21:41:41.987 に答える