So I\'m trying to create a load more button (not infinite scroll although some simple js tweaks could make it so). I\'m using the will_paginate gem in Rails 5.
Its curre
If you check the server console, you can actually see two requests coming in, one triggered by your :remote => true
enabled link and other from your custom ajax. Actually you don't need any js
to make this work. Just remove that click function from your pagination.js.coffee
or remove :remote => true
from the link. After all both are doing the same thing. Hope this will help.
So it was a stupid error of course.
Remove the line on index.html.erb:
:remote => true if @links.next_page
So now it looks like this:
<div class="link-wrap">
<%= render @links %>
</div>
<% if @links.next_page %>
<div class="link more">
<%= link_to 'Load More', links_path(:page => @links.next_page), :class => 'next_page' %>
</div>
<% end %>
All works fine now!