[英]How to keep search box input in search box when submitted Elasticsearch
Using elastic search with searchkick on a rails 4 app.在 rails 4 应用程序上使用带有 searchkick 的弹性搜索。
I would like the input(query) the user types into the search box to stay there after the submit button is clicked and the page is redirected.我希望用户在搜索框中键入的输入(查询)在单击提交按钮并重定向页面后留在那里。 Every page of my app has a search bar so keeping the users input in the box would be great.我的应用程序的每个页面都有一个搜索栏,因此将用户输入保留在框中会很棒。 As of now the search box clears after submitting.截至目前,搜索框在提交后清除。
Having some trouble doing this.这样做有点麻烦。 Have tried a few different methods but nothing is working.尝试了几种不同的方法,但没有任何效果。 Here is my search bar view:这是我的搜索栏视图:
<%= form_tag articles_path, method: :get do %>
<p>
<%= text_field_tag :query, params[:query], style:"width:550px; height:34px;", :autofocus => true, class: "form-control" %><br>
<%= submit_tag "Let's Find Out!", :name => nil, class: "btn btn-default", style: "margin-top:6px; margin-right: 10px;" %><%= submit_tag "Most Popular", :name => nil, class: "btn btn-default", style: "margin-top:6px; margin-left: 10px;" %>
</p>
<% end %>
Any suggestions would be greatly appreciated.任何建议将不胜感激。
A couple quick suggestions:几个快速建议:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.