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.
My code is
<%= text_field_tag :search, params[:search], "data-provide" => "typeahead", "data-source" => '["USA", "Canada","Mexico"]' %>
Can anyone help?
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"]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With