gpt4 book ai didi

javascript - Rails Kaminari 示例无限滚动不起作用

转载 作者:行者123 更新时间:2023-11-27 22:56:36 26 4
gpt4 key购买 nike

我正在尝试使用此示例来实现 kaminarirails 无限滚动。它在我的其他应用程序中运行良好,但在此应用程序中不起作用。 Kaminari example

我的公司财务总监

def index
@companies = Company.all.page(params[:page]).per(4)
end

我的index.html.erb

<div class="posts">
<div class="page">
<%= render @companies %>
</div>
</div>
<%= paginate @companies %>

我的_company.html.erb

<div class="post">
<% company_decorator = CompanyDecorator.new(company)%>
<h4><%= company.name %> ||
No. of operations: <%= company_decorator.number_of_operations %> ||
Average Amount : <%= company_decorator.average_of_amount %> ||
Highest of Month: <%= company_decorator.highest_of_month%> ||
Accepted Operations: <%= company_decorator.accepted_operations%>
</h4>
<ul>
<% company.operations.each do |operation| %>
<li><%= operation.id%></li>

<%end%>
</ul>
</div>

我的 Assets /javascripts/companies.js.coffee

$(document).ready ->
$(".posts .page").infinitescroll
navSelector: "nav.pagination"
nextSelector: "nav.pagination a[rel=next]"
itemSelector: ".posts .post"

我的index.js.erb

$(".posts").append("<div class='page'><%= escape_javascript(render(@companies)) %></div>");

我找不到问题,请帮助我。相同的代码正在我的其他应用程序中运行。

最佳答案

尝试一下
定义索引
@companies = Company.all.page(params[:page]).per(25)
结尾
玩弄分页长度..我听说有时会起作用

关于javascript - Rails Kaminari 示例无限滚动不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37552093/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com