Fix pagination for ajax views
This commit is contained in:
parent
adf5968ad0
commit
9b4c8027b8
|
@ -9,7 +9,7 @@ class GroupController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ class InboxController < ApplicationController
|
|||
@disabled = true if @inbox.empty?
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class NotificationsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class PublicController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ class QuestionController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class StaticController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js { render layout: false }
|
||||
end
|
||||
else
|
||||
return render 'static/front'
|
||||
|
|
|
@ -19,7 +19,7 @@ class UserController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,7 +78,11 @@ class UserController < ApplicationController
|
|||
@users_last_id = @users.map(&:id).min
|
||||
@more_data_available = !@user.cursored_followers(last_id: @users_last_id, size: 1).count.zero?
|
||||
@type = :friend
|
||||
render 'show_follow'
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render "show_follow" }
|
||||
format.js { render "show_follow", layout: false }
|
||||
end
|
||||
end
|
||||
|
||||
def friends
|
||||
|
@ -88,7 +92,11 @@ class UserController < ApplicationController
|
|||
@users_last_id = @users.map(&:id).min
|
||||
@more_data_available = !@user.cursored_friends(last_id: @users_last_id, size: 1).count.zero?
|
||||
@type = :friend
|
||||
render 'show_follow'
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render "show_follow" }
|
||||
format.js { render "show_follow", layout: false }
|
||||
end
|
||||
end
|
||||
|
||||
def questions
|
||||
|
@ -97,6 +105,11 @@ class UserController < ApplicationController
|
|||
@questions = @user.cursored_questions(author_is_anonymous: false, last_id: params[:last_id])
|
||||
@questions_last_id = @questions.map(&:id).min
|
||||
@more_data_available = !@user.cursored_questions(author_is_anonymous: false, last_id: @questions_last_id, size: 1).count.zero?
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js { render layout: false }
|
||||
end
|
||||
end
|
||||
|
||||
def data
|
||||
|
|
|
@ -7,4 +7,4 @@ module LayoutsHelper
|
|||
@haml_buffer.buffer.replace output
|
||||
self.output_buffer = ActionView::OutputBuffer.new(output)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
.media
|
||||
= render "notifications/type/#{notification.target_type.downcase}", notification: notification
|
||||
|
||||
= render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type]
|
||||
- unless @notifications.count.zero?
|
||||
= render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type]
|
||||
|
||||
- if @more_data_available
|
||||
%button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @notifications_last_id }}
|
||||
Load more
|
||||
- if @more_data_available
|
||||
%button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @notifications_last_id }}
|
||||
Load more
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$('#notifications').append('<% @notifications.each do |notification|
|
||||
%><%= j render 'notifications/notification', notification: notification
|
||||
%><% end %>');
|
||||
%><li class="list-group-item"><div class="media"><%= j render "notifications/type/#{notification.target_type.downcase}", notification: notification
|
||||
%></div></li><% end %>');
|
||||
<% if @more_data_available %>
|
||||
$('#pagination').html('<%= j render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type] %>');
|
||||
<% else %>
|
||||
|
|
Loading…
Reference in New Issue