From e3bc0d6300bdeb8a82f0976c3178f21c834980e8 Mon Sep 17 00:00:00 2001 From: Andreas N Date: Thu, 12 Feb 2015 21:59:46 +0100 Subject: [PATCH] add inbox pagination --- app/views/inbox/show.html.haml | 6 ++++++ app/views/inbox/show.js.erb | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 app/views/inbox/show.js.erb diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.html.haml index 0d9098b2..0619f301 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.html.haml @@ -8,6 +8,12 @@ - @inbox.each do |i| = render 'inbox/entry', i: i + #pagination= will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false + + - if @inbox.next_page + %button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @inbox.current_page }} + Load more + - if @inbox.empty? Nothing to see here. diff --git a/app/views/inbox/show.js.erb b/app/views/inbox/show.js.erb new file mode 100644 index 00000000..5b6366c9 --- /dev/null +++ b/app/views/inbox/show.js.erb @@ -0,0 +1,8 @@ +$('#timeline').append('<% @timeline.each do |answer| + %><%= j render 'inbox/entry', a: answer +%><% end %>'); +<% if @timeline.next_page %> +$('#pagination').html('<%= j will_paginate @inbox, renderer: BootstrapPagination::Rails, page_links: false %>'); +<% else %> +$('#pagination, #load-more-btn').remove(); +<% end %> \ No newline at end of file