Skip to content

Instantly share code, notes, and snippets.

@richardsondx
Created April 3, 2012 03:29
Show Gist options
  • Save richardsondx/2289078 to your computer and use it in GitHub Desktop.
Save richardsondx/2289078 to your computer and use it in GitHub Desktop.
Pagination with ajax+kaminari won't paginate @microposts block
gem 'kaminari'
<% for micropost in @microposts %>
<span class="article">
<ul>
<li class="headshot"><%= image_tag("#{ micropost.to_guys ? "guys" : "girl" }-head.png") %></li>
<li class="tipscontent"><p><%= link_to micropost.content, page_path(micropost) %></p></li>
<li class="fbshare">
<a href="https://twitter.com/share" class="twitter-share-button" data-via="twitterapi" data-lang="en" data-hashtags="hmdy">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</li>
</ul>
</span>
<% end %>
<!-- BEGINNING of CONTAINER here-->
<div id="container">
<div id="separator"><p>What People Are Saying</p></div>
<div id="section">
<tbody id="thepost">
<%= render "post" %>
</tbody>
<div id="paginkamari" align="center"><p><%= paginate @microposts, :remote => :true %></p></div>
</div>
<div id="footer">
<p>About Advertising Contact us</p>
</div>
</div>
<!-- END of CONTAINER here-->
$('#thepost').html('<%= escape_javascript render("post") %>');
$('#paginkamari').html('<%= escape_javascript(paginate(@microposts, :remote => true).to_s) %>');
<% for micropost in @microposts %>
<span class="article">
<ul>
<li class="headshot"><%= image_tag("#{ micropost.to_guys ? "guys" : "girl" }-head.png") %></li>
<li class="tipscontent"><p><%= link_to micropost.content, page_path(micropost) %></p></li>
<li class="fbshare">
<a href="https://twitter.com/share" class="twitter-share-button" data-via="twitterapi" data-lang="en" data-hashtags="hmdy">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</li>
</ul>
</span>
<% end %>
<!-- BEGINNING of CONTAINER here-->
<div id="container">
<div id="separator"><p>What People Are Saying</p></div>
<div id="section">
<tbody id="thepost">
<%= render "post" %>
</tbody>
<div id="paginkamari" align="center"><p><%= paginate @microposts, :remote => :true %></p></div>
</div>
<div id="footer">
<p>About Advertising Contact us</p>
</div>
</div>
<!-- END of CONTAINER here-->
$('#thepost').html('<%= escape_javascript render("post") %>');
$('#paginkamari').html('<%= escape_javascript(paginate(@microposts, :remote => true).to_s) %>');
def index
@title = "Home"
@microposts = Micropost.order("created_at").page(params[:page]).per(6)
respond_to do |format|
format.html
format.js
format.xml { render :xml => @microposts }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment