Bootstrap Typeahead仅显示首字母

编程入门 行业动态 更新时间:2024-10-27 07:22:35
本文介绍了Bootstrap Typeahead仅显示首字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我很难让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仅显示首字母

本文发布于:2023-10-23 19:37:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521819.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:首字母   Bootstrap   Typeahead

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!