Pagination fix

This commit is contained in:
Andreas Stephanides
2014-09-13 18:14:27 +02:00
parent 0658a8b423
commit 7a7128aa32
5 changed files with 13 additions and 8 deletions

View File

@@ -1,10 +1,16 @@
jQuery ->
$ ->
if $('#infinite-scrolling').size() > 0 if $('#infinite-scrolling').size() > 0
more_posts_url = $('.pagination .next_page a').attr('href')
b=$(document).height() - $(window).height() - 60
if more_posts_url && $(window).scrollTop() > b
$('.pagination').html('<b> Loading...</b>')
$.getScript more_posts_url
$(window).on 'scroll', -> $(window).on 'scroll', ->
more_posts_url = $('.pagination .next_page a').attr('href') more_posts_url = $('.pagination .next_page a').attr('href')
b=$(document).height() - $(window).height() - 60 b=$(document).height() - $(window).height() - 60
if more_posts_url && $(window).scrollTop() > b if more_posts_url && $(window).scrollTop() > b
$('.pagination').html('<b> Loading...</b>') $('.pagination').html('<b> Loading...</b>')
$.getScript more_posts_url $.getScript more_posts_url
return return
return return

View File

@@ -7,7 +7,7 @@ class RubrikenController < ApplicationController
@neuigkeiten = Neuigkeit.paginate(page: params[:page], per_page:3) @neuigkeiten = Neuigkeit.paginate(page: params[:page], per_page:3)
else else
@rubriken = Rubrik.where(:public=>true) @rubriken = Rubrik.where(:public=>true)
@neuigkeiten = Neuigkeit.public.recent @neuigkeiten = Neuigkeit.public.published.paginate(page: params[:page], per_page:3)
end end
@calentries= @rubriken.collect(&:calentries).flatten @calentries= @rubriken.collect(&:calentries).flatten

View File

@@ -1,6 +1,6 @@
<% if defined?(wrap_in) && !wrap_in.blank? %> <% if defined?(wrap_in) && !wrap_in.blank? %>
<%= content_tag wrap_in do %> <%= content_tag wrap_in do %>
www
<% c =[:linkbox] %> <% c =[:linkbox] %>
<% c << "color-"+neuigkeit.rubrik.color.to_s+"-dark" unless neuigkeit.rubrik.color.nil? %> <% c << "color-"+neuigkeit.rubrik.color.to_s+"-dark" unless neuigkeit.rubrik.color.nil? %>
<%= link_to [neuigkeit.rubrik,neuigkeit], {class: c} do %> <%= link_to [neuigkeit.rubrik,neuigkeit], {class: c} do %>

View File

@@ -22,9 +22,8 @@
<ul class="unstyled linkbox-list" style="max-width:70em" id="neuigkeiten"> <ul class="unstyled linkbox-list" style="max-width:70em" id="neuigkeiten">
<% @neuigkeiten.each do |neuigkeit| %> <% @neuigkeiten.each do |neuigkeit| %>
<li>
<%= render neuigkeit %> <%= render neuigkeit, wrap_in: "li" %>
</li>
<% end %> <% end %>
</ul> </ul>

View File

@@ -1,4 +1,4 @@
$('#neuigkeiten').append('<%= j render @neuigkeiten, :locals => { :wrap_in => :li} %>'); $('#neuigkeiten').append('<%= j render @neuigkeiten, :wrap_in => :li %>');
<% if @neuigkeiten.next_page %> <% if @neuigkeiten.next_page %>
$('.pagination').replaceWith('<%= j will_paginate @neuigkeiten %>'); $('.pagination').replaceWith('<%= j will_paginate @neuigkeiten %>');
<% else %> <% else %>