Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Typeahead text field name attrib messes with autocomplete

I am using the typeahead js extension from twitter bootstrap for an autocomplete field. I have a subtle problem with that. I have a text field like :

<%= text_field_tag :search, params[:search], :data => { :provide => 'typeahead', :source => ...} %>

The problem is that i have to specify name='search' (with :search), in order to be able to grab the text input search value. However, if i do so, the browser automatically creates an autocomplete history of the entries i have already tried in my text field.

If i remove :search and replace with '', the browser cannot 'save' the history, because there is no name attribute on the text field. However, this way, i cannot get the inputted value myself.

How can i work around this ?

like image 414
Spyros Avatar asked May 01 '12 02:05

Spyros


1 Answers

When I use autocomplete from jquery-ui, it sets the attribute autocomplete="off" in the input tag, so you might try including the option :autocomplete=>"off". The field doesn't show any inputs from the history, just what was passed in to autocomplete.

If that doesn't work, just try jquery-ui's autocomplete instead. It definitely works.

like image 114
cdesrosiers Avatar answered Oct 01 '22 03:10

cdesrosiers