Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我应该如何在Rails中将jQuery与Sunspot一起使用?_Jquery_Ruby On Rails_Sunspot - Fatal编程技术网

我应该如何在Rails中将jQuery与Sunspot一起使用?

我应该如何在Rails中将jQuery与Sunspot一起使用?,jquery,ruby-on-rails,sunspot,Jquery,Ruby On Rails,Sunspot,我只想在同一页中显示搜索结果,而不重定向到默认的搜索链接,如“……搜索=&commit=search”。我的初衷是使用jQuery呈现与搜索结果相同的表单。 远程选项设置如下 > <%= form_tag index_by_dvp_path,:method => :get do %> > <p> > <%= text_field_tag :search, params[:search] %> >

我只想在同一页中显示搜索结果,而不重定向到默认的搜索链接,如“……搜索=&commit=search”。我的初衷是使用jQuery呈现与搜索结果相同的表单。 远程选项设置如下

>   <%= form_tag index_by_dvp_path,:method => :get do %>
>        <p>
>           <%= text_field_tag :search, params[:search] %>
>           <%= submit_tag "Search",remote: true %>
>        </p>
>        <% end %>
>:获取do%>
>
>           
>           
>

>
但是当我点击搜索按钮时,页面仍然重定向到我提到的默认链接


我不确定问题出在哪里。

您可以对搜索表单使用
:remote=>true
选项

<%= form_tag index_by_dvp_path,:method => :get, :remote => true do %>
  <p>
   <%= text_field_tag :search, params[:search] %>
   <%= submit_tag "Search",remote: true %>
  </p>
<% end %>
在dvp.js.erb的索引中

$('#your_div_for_search_result').html("<%= escape_javascript(render :partial => 'your_search_partial')%>")
$('your#div_for_search_result').html('your_search_partial')%>)
$('#your_div_for_search_result').html("<%= escape_javascript(render :partial => 'your_search_partial')%>")