Last active
August 30, 2017 17:57
-
-
Save seguelador/33e5fad3e6bd3e1ece18ae8bbaa37fdd to your computer and use it in GitHub Desktop.
Will Paginate Boostrap with Ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @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" } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="products"> | |
<%= render "products/products" %> | |
</div> | |
<script> | |
$(function(){ | |
$('.pagination a').attr('data-remote', 'true') | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#products").html('<%= escape_javascript(render :partial => 'products/products') %>'); | |
$('.pagination a').attr('data-remote', 'true'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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