Bootstrap Typeahead仅显示首字母 [英] Bootstrap Typeahead only displaying first letter
问题描述
我很难让Twitter Bootstrap的Typeahead正常工作。提前输入仅与输入的第一个字母匹配。我在预先输入框中的结果看起来像是
I'm having a tough time getting Twitter Bootstrap's Typeahead to work. Typeahead is only matching the first letter of an input. My results in the typeahead box looks something like
n
n
n
N
N
n.
我的代码是
<%= text_field_tag :search, params[:search], "data-provide" => "typeahead", "data-source" => '["USA", "Canada","Mexico"]' %>
有人可以帮忙吗?
推荐答案
检查html中数据源属性的引号组合。我在以下代码段中遇到了同样的问题。
Check the combination of quotes that's output in your html for the data-source attribute. I was having the same problem with the following snippet of code.
<input type="text" name="test" id="test" class="span2" data-provide="typeahead"
data-items="4" data-source="['thisone','another','zzzz']">
更改为以下内容(我在其他示例中看到过)并没有解决
changing to the following, which I've seen in other examples, didn't fix it
data-source="["thisone","another","zzzz"]"
,但是切换到属性值的单引号和可搜索元素的双引号将其固定。 这有效。
but switching to single quotes around the attribute value and double-quotes for the searchable elements fixed it. This works.
data-source='["thisone","another","zzzz"]'
这篇关于Bootstrap Typeahead仅显示首字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!