Skip to content

Commit

Permalink
Fix #812 修正新回复提醒点击以后,回帖总数丢失的问题。
Browse files Browse the repository at this point in the history
Ajax 的 partial 带有类变量,导致在其他区域调用会缺少数据的问题
  • Loading branch information
huacnlee committed Nov 30, 2016
1 parent 236a50d commit 968e533
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/controllers/replies_controller.rb
Expand Up @@ -10,7 +10,6 @@ def create
@reply.user_id = current_user.id

if @reply.save
@replies_count = @topic.replies_count + 1
current_user.read_topic(@topic)
@msg = t('topics.reply_success')
else
Expand Down
6 changes: 3 additions & 3 deletions app/views/replies/_create_callback.js.erb
Expand Up @@ -3,10 +3,10 @@ if($("#replies").length == 0){
} else {
if ($(".reply[data-id=<%= reply.id %>]").length == 0) {
var current_floor = parseInt($("#replies").data("last-floor")) + 1;
var dom = $('<%= j(render("reply", reply: reply, reply_counter: @topic.replies_count - 1, display_edit: true)) %>');
var dom = $('<%= j(render("reply", reply: reply, reply_counter: reply.topic.replies_count - 1, display_edit: true)) %>');
$("#replies .items").append(dom);
$("#replies .total b").text('<%= @replies_count %>');
$('#topic-sidebar .total b').text('<%= @replies_count %>');
$("#replies .total b").text('<%= reply.topic.replies_count %>');
$('#topic-sidebar .total b').text('<%= reply.topic.replies_count %>');
dom.find(".reply-floor").text(current_floor + " 楼");
dom.find("a.edit").css("display", "inline-block");
dom.addClass('light');
Expand Down

0 comments on commit 968e533

Please sign in to comment.