Adt Adt - 4 months ago 63x
Javascript Question

Rails Kaminari example infinite scroll not working

I am trying to implement kaminari rails infinite scroll using this example.
It is working fine in my other apps but not working in this app.
Kaminari example

My company controller

def index
@companies =[:page]).per(4)

My index.html.erb

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

My _company.html.erb

<div class="post">
<% company_decorator =>
<h4><%= %> ||
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%>
<% company.operations.each do |operation| %>


My assets/javascripts/

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

My index.js.erb

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

I am unable to find problem please help me. This same code is working in my other app.


Try def index @companies =[:page]).per(25) end playing with the pagination length.. I've heard that sometimes works