I have a form with text field:
<%= 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 the text field?
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 %>
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