我有模型称为搜索从数据库渲染数据,使用索引方法我正在访问3个模型的数据,并将其显示在索引页上。 我使用的form_tag索引页面本身,Rails的form_tag提交数据,而无需重新加载整个页面
<%= form_tag(search_path, :method => "get", :remote => true, id: "search-form") do %>
<label for="Longitude ">Lon</label>
<%= text_field_tag :lng, params[:lng], :id => "longitude", placeholder: "Longitude" %>
<label for="Latitude ">Lat</label>
<%= text_field_tag :lat, params[:lat], :id => "latitude", placeholder: "Latitude" %>
<button class="btn waves-effect waves-light" >Process</button>
<% end %>
我还没有建立这方面的任何局部视图。
我添加了:remote => true在form_tag中,我不知道在哪里以及如何为此调用ajax? 我正在从表中搜索数据并使用'<%= escape_javascript @ center_lat.to_json%>获取更新的数据';在index.html.erb文件中
任何帮助将是可观的。
我已经加入到format.js我的控制器索引操作,创建.js,erb视图,但在该视图中如何呈现索引操作? – Pbms
看看这里:http://guides.rubyonrails.org/working_with_javascript_in_rails.html#server-side-concerns,你需要使用一些JavaScript来呈现你的结果,而无需重新加载页面。 – Victor