0

我正在使用 bootstrap typeahead 来实现自动完成功能。当输入激活时(在鼠标单击或选项卡上输入),我需要预先输入以返回结果,而不是等待用户输入第一个字符。更像是打字机。

<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 回答
0

Bootstrp 组合框完美运行

于 2013-06-19T00:37:32.170 回答