Created
December 30, 2013 11:11
-
-
Save Gedrovits/8180789 to your computer and use it in GitHub Desktop.
Kaminari-powered shared paginator
This file contains 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
-# shared/_index.js.haml | |
:plain | |
$("##{escape_javascript models.first.class.name.tableize.dasherize}").html("#{escape_javascript render(models)}"); | |
$('#pager').html("#{escape_javascript(paginate(models, remote: true).to_s)}#{escape_javascript(page_entries_info models)}"); |
This file contains 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
-# shared/_pager.html.haml | |
- remote = remote ? remote : false | |
#pager.centered | |
= paginate models, remote: remote | |
= page_entries_info models |
This file contains 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
# Controller action example | |
class ExamplesController < ApplicationController | |
def index | |
@examples = Example.page params[:page] | |
respond_to do |format| | |
format.html #index.html.haml | |
format.json { render json: @examples } | |
format.js { render partial: 'shared/index', locals: { models: @examples } } | |
end | |
end | |
end |
This file contains 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
-# examples/index.html.haml | |
%table#examples.custom.table.table-bordered.table-striped.table-condensed | |
%thead | |
%tr | |
%th One | |
%th Two | |
%th Three | |
%tbody | |
= render @examples | |
= render 'shared/pager', models: @examples, locals: { remote: true } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment