Ruby on Rails:如何从搜索框中清除条目

时间:2014-01-02 14:14:55

标签: html ruby-on-rails ruby-on-rails-3

我使用的搜索框使用以下格式:

<div id='search-box'>
  <%= form_tag "/search", :method => :get, :id => "search-form" do %>
    <%= text_field_tag :q, params[:q], {:id => "search-text", :placeholder => "SEARCH FOR PRODUCTS"} %>
    <%= submit_tag "Go" %>
  <%end%>
</div>

问题是每当我在搜索框中输入内容时,它会显示以前查询的下拉列表。我不想存储查询并显示下拉列表。如何清除查询?

1 个答案:

答案 0 :(得分:1)

使用autocomplete="off"

<%= text_field_tag :q, params[:q], {:id => "search-text", :placeholder => "SEARCH FOR PRODUCTS", :autocomplete => 'off'} %>