Skip to content Skip to sidebar Skip to footer

Endless Scrolling Does Not Work

Update: My Github Repository https://github.com/Marc585/smartforce2 i just finished the onemonthrails tutorial. at the last chapter its about endless scrolling. i tripple checked m

Solution 1:

You are missing

format.js in your show action in the pins_controller.rb. This is from the onemonth rails notes

Note: You'll have to create an analogous show.js.erb and add the format.js option to your users#show action to get endless scroll to work on users' profile pages as well

defshow@pin = Pin.find(params[:id])
 respond_to do |format|
  format.html # show.html.erbformat.json { render json: @pin }
  format.js
 end
end

Your show.js.erb should look like this

boxes = $('<%= j render(@pins) %>')

$('#pins').append( $boxes ).imagesLoaded( function(){
   $('#pins').masonry( 'reload');
});
<% if@pins.next_page %>
   $('.pagination').replaceWith('<%= j will_paginate(@pins) %>');
<% else %>
   $('.pagination').remove();
<% end %>

Post a Comment for "Endless Scrolling Does Not Work"