关注人数变化

This commit is contained in:
lizanle 2015-08-26 14:39:33 +08:00
parent da47f5bb00
commit d500ea0790
3 changed files with 6 additions and 4 deletions

View File

@ -41,7 +41,7 @@ class WatchersController < ApplicationController
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add',:list => @list,:action_name=>params[:action_name],:page=>params[:page]} }
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add',:list => @list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
end
rescue Exception => e
if e.message == "404"
@ -73,7 +73,7 @@ class WatchersController < ApplicationController
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (false ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete',:list=>@list,:action_name=>params[:action_name],:page=>params[:page]} }
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete',:list=>@list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
end
rescue Exception => e
if e.message == "404"

View File

@ -11,13 +11,13 @@
<div class="courses_top mb10" id="<%= (@action == 'fans' || @action == 'visitor' ) ? 'nh_fans_list' : 'nh_wacth_list' %>">
<% if @action == 'fans' %>
<h2 class="courses_h2 fl">粉丝</h2>
<div class="courses_select fr">共有<span class="c_orange" nh_name="fans_count"><%=@obj_count%></span>名粉丝</div>
<div class="courses_select fr">共有<span class="c_orange" nh_name="fans_count" id="fans_span"><%=@obj_count%></span>名粉丝</div>
<% elsif @action == 'visitor' %>
<h2 class="courses_h2 fl">访客</h2>
<div class="courses_select fr">共有<span class="c_orange"><%=@obj_count%></span>访客</div>
<% else %>
<h2 class="courses_h2 fl">关注</h2>
<div class="courses_select fr">一共关注<span class="c_orange" nh_name="watcher_count"><%=@obj_count%></span>人</div>
<div class="courses_select fr">一共关注<span class="c_orange" nh_name="watcher_count" id="watch_span"><%=@obj_count%></span>人</div>
<% end %>
<div class="cl"></div>
</div>

View File

@ -8,6 +8,8 @@
$("#users_list").html("<%= escape_javascript (render :partial => 'users/user_fans_item', :locals => {:list => list,:target=>User.current,:action_name=>action_name,:page=>params[:page]}) %>");
$("#watch_user_number_div").html('<%= escape_javascript ( link_to User.watched_by(params[:target_id]).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>params[:target_id]},:class=>"homepageImageNumber") %>');
$("#fans_user_number_div").html('<%= escape_javascript ( link_to User.find(params[:target_id]).watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>params[:target_id]},:class=>"homepageImageNumber", :id => "user_fans_number") %>');
$("#fans_span").html('<%= count %>');
$("#watch_span").html('<%= count %>');
//在其他用户的粉丝、关注页面
<% else %>
$("#users_list").html("<%= escape_javascript (render :partial => 'users/user_fans_item', :locals => {:list => list,:target=>User.find(params[:target_id]),:action_name=>action_name,:page=>params[:page]}) %>");