Commit 0a52b55826bdb0514dfb41d61c9d3aa7bf34c0e9
1 parent
8ab1f90e
Exists in
staging
and in
4 other branches
proposals_discussion: fix infinite loading bug
Showing
4 changed files
with
14 additions
and
13 deletions
Show diff stats
plugins/proposals_discussion/controllers/public/proposals_discussion_plugin_public_controller.rb
| ... | ... | @@ -11,11 +11,7 @@ class ProposalsDiscussionPluginPublicController < ApplicationController |
| 11 | 11 | @proposals = order_proposals(@holder.proposals.public, order) |
| 12 | 12 | @proposals = @proposals.page(page).per_page(4) |
| 13 | 13 | |
| 14 | - unless @proposals.empty? | |
| 15 | - render :partial => 'content_viewer/proposals_list_content', :locals => {:proposals => @proposals, :holder => @holder, :page => page+1, :order => order} | |
| 16 | - else | |
| 17 | - render :text => '' | |
| 18 | - end | |
| 14 | + render :partial => 'content_viewer/proposals_list_content', :locals => {:proposals => @proposals, :holder => @holder, :page => page+1, :order => order} | |
| 19 | 15 | end |
| 20 | 16 | |
| 21 | 17 | private | ... | ... |
plugins/proposals_discussion/public/proposals_list.js
| ... | ... | @@ -10,11 +10,16 @@ jQuery(document).ready(function($) { |
| 10 | 10 | }); |
| 11 | 11 | |
| 12 | 12 | function proposalsScroll() { |
| 13 | - $('.article-body-proposals-discussion-plugin_topic .topic-content').data('jscroll', null); | |
| 14 | - $('.article-body-proposals-discussion-plugin_topic .topic-content').jscroll({ | |
| 15 | - loadingHtml: '<img src="/images/loading.gif" alt="Loading" />Loading...', | |
| 16 | - nextSelector: 'div.more a' | |
| 17 | - }); | |
| 13 | + var scroll = $('.article-body-proposals-discussion-plugin_topic .topic-content .proposals_list'); | |
| 14 | + var nextSelector = 'div.more a'; | |
| 15 | + if(scroll.data('jscroll')) scroll.jscroll.destroy(); | |
| 16 | + | |
| 17 | + if(scroll.find(nextSelector).length > 0) { | |
| 18 | + scroll.jscroll({ | |
| 19 | + loadingHtml: '<img src="/images/loading.gif" alt="Loading" />Loading...', | |
| 20 | + nextSelector: nextSelector | |
| 21 | + }); | |
| 22 | + } | |
| 18 | 23 | } |
| 19 | 24 | $('.filters .random').click(); |
| 20 | 25 | ... | ... |
plugins/proposals_discussion/test/functional/proposals_discussion_plugin_public_controller_test.rb
| ... | ... | @@ -22,9 +22,9 @@ class ProposalsDiscussionPluginPublicControllerTest < ActionController::TestCase |
| 22 | 22 | assert_match /href=.*page=2/, response.body |
| 23 | 23 | end |
| 24 | 24 | |
| 25 | - should 'render blank text if it is the last page' do | |
| 25 | + should 'not render more link if it was the last page' do | |
| 26 | 26 | get :load_proposals, :profile => profile.identifier, :holder_id => topic.id |
| 27 | - assert_equal '', response.body | |
| 27 | + assert_select 'div.more a', 0 | |
| 28 | 28 | end |
| 29 | 29 | |
| 30 | 30 | should 'load proposals with alphabetical order' do | ... | ... |
plugins/proposals_discussion/views/content_viewer/_proposals_list_content.html.erb