修复了关注后不刷新页面中粉丝数的功能。
This commit is contained in:
parent
62e6213113
commit
1cf8b8bbd1
|
@ -100,6 +100,7 @@ class WatchersController < ApplicationController
|
||||||
def set_watcher(watchables, user, watching)
|
def set_watcher(watchables, user, watching)
|
||||||
watchables.each do |watchable|
|
watchables.each do |watchable|
|
||||||
watchable.set_watcher(user, watching)
|
watchable.set_watcher(user, watching)
|
||||||
|
@user = watchable # added by william
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
||||||
|
|
|
@ -1316,4 +1316,9 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
#added by william
|
||||||
|
def get_fans_num(user)
|
||||||
|
user.watcher_users.count
|
||||||
|
end
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= l(:label_user_watcher) %> (<strong class="font_small_watch"><%= User.watched_by(@user.id).count %></strong>)
|
<%= l(:label_user_watcher) %> (<strong class="font_small_watch"><%= User.watched_by(@user.id).count %></strong>)
|
||||||
<%= 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>
|
</div>
|
||||||
<div class="user_underline"></div>
|
<div class="user_underline"></div>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<span id="fans_num">
|
||||||
|
<%= l(:label_user_fans) %>(<strong class="font_small_watch"><%= fans_num %></strong>)
|
||||||
|
</span>
|
|
@ -1,2 +1,5 @@
|
||||||
<% selector = ".#{watcher_css(watched)}" %>
|
<% selector = ".#{watcher_css(watched)}" %>
|
||||||
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
|
$("<%= 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) }
|
||||||
|
) %>');
|
||||||
|
|
Loading…
Reference in New Issue