【问题标题】:Getting typeahead working提前输入工作
【发布时间】:2014-07-10 16:26:39
【问题描述】:

这可能是一个愚蠢的问题,但我在让 twitter 的 typeahead 工作时遇到问题。

从工作教程 here,我将代码复制到 JS fiddle 中,并带有引导和预输入。

我只是在处理一个简单的文本字段:

<input class="typeahead" type="text" placeholder="States of USA">

【问题讨论】:

  • 你缺少元素 #the-basics 应用了 CSS + 小提琴没有包含 jquery,请参阅 jsfiddle.net/eq4p8/1

标签: jquery twitter-bootstrap bootstrap-typeahead twitter-typeahead


【解决方案1】:

按照教程,我们需要一个包装器 div 用于输入,它将应用 CSS 并在其中创建 DOM 元素。

关于声明我们有:

$('#the-basics .typeahead').typeahead({
  hint: true,
  highlight: true,
  minLength: 1
}

意味着我们的包装器将是#the-basics,正如教程中所做的那样,我们需要添加包装器:

<input class="typeahead" type="text" placeholder="States of USA">

作为:

<div id="the-basics">
    <input class="typeahead" type="text" placeholder="States of USA" />
</div>

FIDDLE: http://jsfiddle.net/eq4p8/1/

【讨论】:

  • 非常感谢!我知道这一定是我缺少的一些简单的东西!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-14
  • 1970-01-01
相关资源
最近更新 更多