修复了关注后不刷新页面中粉丝数的功能。

This commit is contained in:
william 2013-08-10 17:07:29 +08:00
parent 62e6213113
commit 1cf8b8bbd1
5 changed files with 13 additions and 1 deletions

View File

@ -100,6 +100,7 @@ class WatchersController < ApplicationController
def set_watcher(watchables, user, watching)
watchables.each do |watchable|
watchable.set_watcher(user, watching)
@user = watchable # added by william
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}

View File

@ -1316,4 +1316,9 @@ module ApplicationHelper
end
# end
#added by william
def get_fans_num(user)
user.watcher_users.count
end
#end
end

View File

@ -51,7 +51,7 @@
<div>
<%= l(:label_user_watcher) %> (<strong class="font_small_watch"><%= User.watched_by(@user.id).count %></strong>) &nbsp;
<%= l(:label_user_fans) %>(<strong class="font_small_watch"><span id="fans_num"><%= @user.watcher_users.count %></span></strong>)
<%= render :partial => "watchers/fans_num",:locals => {:fans_num => get_fans_num(@user) }%>
</div>
</div>
<div class="user_underline"></div>

View File

@ -0,0 +1,3 @@
<span id="fans_num">
<%= l(:label_user_fans) %>(<strong class="font_small_watch"><%= fans_num %></strong>)
</span>

View File

@ -1,2 +1,5 @@
<% selector = ".#{watcher_css(watched)}" %>
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
$('#fans_num').html('<%= j(render :partial => "/watchers/fans_num",:locals => {:fans_num => get_fans_num(@user) }
) %>');