如何使用分页宝石(will_paginate)无限制地滚动砌体帖子?
这是index.html
<%= render 'users/header' %>
<% if @feed_items.any? %>
<div class="transitions-disabled" id="views">
<%= render @feed_items %>
</div>
<div id="infinite-scrolling">
<%= will_paginate @views, :page_links => false %>
</div>
<% end %>
index.js.erb
文件
$('#views').append('<%= j render @views %>');
<% if @views.next_page %>
$('.pagination').replaceWith('<%= j will_paginate @views %>');
<% else %>
$(window).off('scroll');
$('.pagination').remove();
<% end %>
_view.html.erb
文件
<div class="box panel panel-default">
<% unless view.image.url == "/images/original/missing.png" %>
<%= link_to (image_tag view.image.url), view %>
<% end %>
<div class="user">
<div class="view-title">
<h2><%= link_to view.title, view %></h2>
</div>
<div class="view-user-time">
<div class="user-image">
<%= link_to gravatar_for(view.user, size: 35), view.user %>
</div>
<%= link_to "#{view.user.name} #{view.user.surname}", view.user, class: "user-names" %>
<span>
<%= "#{time_ago_in_words view.created_at} ago" %>
</span>
</div>
</div>
</div>
然而,这种实施工作有一个重大故障,其中分层砌筑柱砖在最初的砖块后面而不是在它们下面。