Ruby on Rails autocomplete form_for using HTML5 Datalist
I have a form with a textbox:
<%= form_for @person do |f| %>
<%= f.label :first_name, "First Name" %>:
<%= f.text_field :first_name %>
<%= f.submit %>
<% end %>
How do I use the HTML5 Datalist element to autocomplete a textbox?
+3
Bruno
source
to share
1 answer
This works for me on Rails 4.2beta.
<%= form_for @person do |f| %>
<%= f.label :first_name, "First Name" %>:
<%= f.text_field :first_name, list: "names" %>
<datalist id="names">
<option value="Kalle">
<option value="Jarmo">
<option value="Pekka">
</datalist>
<%= f.submit %>
<% end %>
+5
luopio
source
to share