title: How to infinite scroll with Kaminari in rails 6?
body: <p>I am looking for solution for infinite scroll with Kaminari in my project, but it still does not work as expected.</p>
  <p>In my home page have view for render post:</p>
  <pre><code>&lt;div class=&quot;home_post_tab_content&quot;&gt;
      &lt;%if @posts.present?%&gt;
          &lt;div id=&quot;home_post_infinite_scroll&quot;&gt;
              &lt;%= render @posts %&gt;
          &lt;/div&gt;
          &lt;%if @posts.total_count &gt; 10%&gt;
              &lt;div class=&quot;home_post_pagination_button&quot; id=&quot;home_post_pagination&quot;&gt;
                  &lt;%= link_to_next_page(@posts, 'Xem thêm', :remote =&gt; true) %&gt;
              &lt;/div&gt;
          &lt;%end%&gt;
      &lt;%end%&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Controller:</p>
  <pre class="lang-rb prettyprint-override"><code>respond_to do |format|
    format.html {}
    format.js
  end
  </code></pre>
  <p>Script file:</p>
  <pre><code>// Append new data
  $(&quot;&lt;%=j render @posts %&gt;&quot;).appendTo($(&quot;#home_post_infinite_scroll&quot;));
  
  // Update pagination link
  &lt;% if @posts.last_page? %&gt;
    $('#home_post_pagination').remove();
  &lt;% else %&gt;
    $('#home_post_pagination').html(&quot;&lt;%=j link_to_next_page(@posts, 'See more', :remote =&gt; true) %&gt;&quot;);
  &lt;% end %&gt;
  </code></pre>
  <p>Q: How can I trigger the next button when user scrolls in end of page (jquery or JS...)?
  Or, If any one has another solution for infinite scroll please let me know. Thanks so much!</p>