Skip to content

Instantly share code, notes, and snippets.

@seguelador
Last active August 30, 2017 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seguelador/33e5fad3e6bd3e1ece18ae8bbaa37fdd to your computer and use it in GitHub Desktop.
Save seguelador/33e5fad3e6bd3e1ece18ae8bbaa37fdd to your computer and use it in GitHub Desktop.
Will Paginate Boostrap with Ajax
<% @products.each do |product| %>
<span> <%= product.title %> </span>
<span> <%= product.price %> </span>
<% end %>
<%= will_paginate @products, renderer: BootstrapPagination::Rails %>
<%#= will_paginate @products, renderer: BootstrapPagination::Rails, :params => { :controller => "optional controller", :action => "optional action" } %>
<div id="products">
<%= render "products/products" %>
</div>
<script>
$(function(){
$('.pagination a').attr('data-remote', 'true')
});
</script>
$("#products").html('<%= escape_javascript(render :partial => 'products/products') %>');
$('.pagination a').attr('data-remote', 'true');
def index
@products = Product.paginate(:page => params[:page], :per_page => 10)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment