Ruby on rails ajax将分页在页面中呈现两次
我正在rails应用程序中使用ajax分页。分页工作正常。但在一个页面中,当我点击下一页链接时。它会显示页面两次。但在其他页面,它工作得很好 这是我的index.js.erb:Ruby on rails ajax将分页在页面中呈现两次,ruby-on-rails,ruby,will-paginate,Ruby On Rails,Ruby,Will Paginate,我正在rails应用程序中使用ajax分页。分页工作正常。但在一个页面中,当我点击下一页链接时。它会显示页面两次。但在其他页面,它工作得很好 这是我的index.js.erb: $('.sort_paginate_ajax').html("<%= escape_javascript(render("jobs"))%>"); $(".tablesorter").tablesorter(); 这是我的作业文件: <tbody> <% @jobs.ea
$('.sort_paginate_ajax').html("<%= escape_javascript(render("jobs"))%>");
$(".tablesorter").tablesorter();
这是我的作业文件:
<tbody>
<% @jobs.each do |job| %>
<tr>
<td><%= job.created_at %></td>
<% @locations = Location.where(:id => job.location_id) %>
<% if(@locations.length != 0) %>
<% @locations.each do |location| %>
<td><%= location.Site %></td>
<td><%= location.City.capitalize %>/<%= location.State.capitalize %></td>
<% end %>
<% end %>
<% @clientlist = Client.where(:id => job.client_id) %>
<% if(@clientlist.length != 0) %>
<% @clientlist.each do |client| %>
<td><%= client.ClientName.capitalize %></td>
<% end %>
<% end %>
<td>TODO</td>
<td>TODO</td>
<td><%= job.SalesOrder %></td>
<td>TODO</td>
<td><%= link_to '', edit_job_path(job),:class =>'edit_icon' %><%= link_to 'X', job, :class=>'rmv-fld', method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<% if @jobs.length!=0 %>
<div class="me-tdy">
<table width="100%" border="0" style="border:none !important" class="table_clr2 table">
<tbody>
<tr>
<td width="90%" align="left" style="border:none"><h2 style="padding:0;" class="job_heading">JOBS</h2></td>
<td width="10%" style="border:none">
<div class="arrow_bx">
<%= ajax_will_paginate @jobs, :params => { :my_excluded_param => nil } %>
</div></td>
</tr>
</tbody></table>
</div>
</div><% else %>
作业位置(id)%>
/
作业.客户id)%>
待办事项
待办事项
待办事项
'编辑图标'>'rmv-fld',方法::删除,数据:{确认:'确定吗?}%>
工作
{:my_excluded_param=>nil}%>
index.js.erb会被渲染两次吗。。更新服务器日志和更多相关代码(如果可能)_jobs.html.erb呈现两次。更新服务器日志并使用PartialID查看文件代码使用firebug检查并检查ajax是否被触发两次。另外,在作业部分使用代码更新您的问题。是的,我检查了firebug,但ajax调用没有两次?
Started GET "/jobs?page=2&_=1400322005679" for 127.0.0.1 at 2014-05-17 15:50:12 +0530
Processing by JobsController#index as JS
Parameters: {"page"=>"2", "_"=>"1400322005679"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 ORDER BY "users"."id" ASC LIMIT 1
Job Load (0.5ms) SELECT "jobs".* FROM "jobs" LIMIT 2 OFFSET 2
(0.3ms) SELECT COUNT(*) FROM "jobs"
Location Load (0.4ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = 2
Client Load (0.4ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = 2
Location Load (0.5ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = 1
Client Load (0.4ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = 1
DEPRECATION WARNING: link_to_function is deprecated and will be removed from Rails 4.1. We recommend using Unobtrusive JavaScript instead. See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript. (called from link at /var/www/selectcom/app/helpers/will_paginate_helper.rb:16)
DEPRECATION WARNING: link_to_function is deprecated and will be removed from Rails 4.1. We recommend using Unobtrusive JavaScript instead. See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript. (called from link at /var/www/selectcom/app/helpers/will_paginate_helper.rb:16)
DEPRECATION WARNING: link_to_function is deprecated and will be removed from Rails 4.1. We recommend using Unobtrusive JavaScript instead. See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript. (called from link at /var/www/selectcom/app/helpers/will_paginate_helper.rb:16)
DEPRECATION WARNING: link_to_function is deprecated and will be removed from Rails 4.1. We recommend using Unobtrusive JavaScript instead. See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript. (called from link at /var/www/selectcom/app/helpers/will_paginate_helper.rb:16)
Rendered jobs/_jobs.html.erb (15.3ms)
Rendered jobs/index.js.erb (18.7ms)
Completed 200 OK in 28ms (Views: 22.5ms | ActiveRecord: 3.0ms)
<tbody>
<% @jobs.each do |job| %>
<tr>
<td><%= job.created_at %></td>
<% @locations = Location.where(:id => job.location_id) %>
<% if(@locations.length != 0) %>
<% @locations.each do |location| %>
<td><%= location.Site %></td>
<td><%= location.City.capitalize %>/<%= location.State.capitalize %></td>
<% end %>
<% end %>
<% @clientlist = Client.where(:id => job.client_id) %>
<% if(@clientlist.length != 0) %>
<% @clientlist.each do |client| %>
<td><%= client.ClientName.capitalize %></td>
<% end %>
<% end %>
<td>TODO</td>
<td>TODO</td>
<td><%= job.SalesOrder %></td>
<td>TODO</td>
<td><%= link_to '', edit_job_path(job),:class =>'edit_icon' %><%= link_to 'X', job, :class=>'rmv-fld', method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<% if @jobs.length!=0 %>
<div class="me-tdy">
<table width="100%" border="0" style="border:none !important" class="table_clr2 table">
<tbody>
<tr>
<td width="90%" align="left" style="border:none"><h2 style="padding:0;" class="job_heading">JOBS</h2></td>
<td width="10%" style="border:none">
<div class="arrow_bx">
<%= ajax_will_paginate @jobs, :params => { :my_excluded_param => nil } %>
</div></td>
</tr>
</tbody></table>
</div>
</div><% else %>