Skip to content

Commit 968e533

Browse files
committed
Fix ruby-china#812 修正新回复提醒点击以后,回帖总数丢失的问题。
Ajax 的 partial 带有类变量,导致在其他区域调用会缺少数据的问题
1 parent 236a50d commit 968e533

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

app/controllers/replies_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def create
1010
@reply.user_id = current_user.id
1111

1212
if @reply.save
13-
@replies_count = @topic.replies_count + 1
1413
current_user.read_topic(@topic)
1514
@msg = t('topics.reply_success')
1615
else

app/views/replies/_create_callback.js.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ if($("#replies").length == 0){
33
} else {
44
if ($(".reply[data-id=<%= reply.id %>]").length == 0) {
55
var current_floor = parseInt($("#replies").data("last-floor")) + 1;
6-
var dom = $('<%= j(render("reply", reply: reply, reply_counter: @topic.replies_count - 1, display_edit: true)) %>');
6+
var dom = $('<%= j(render("reply", reply: reply, reply_counter: reply.topic.replies_count - 1, display_edit: true)) %>');
77
$("#replies .items").append(dom);
8-
$("#replies .total b").text('<%= @replies_count %>');
9-
$('#topic-sidebar .total b').text('<%= @replies_count %>');
8+
$("#replies .total b").text('<%= reply.topic.replies_count %>');
9+
$('#topic-sidebar .total b').text('<%= reply.topic.replies_count %>');
1010
dom.find(".reply-floor").text(current_floor + " 楼");
1111
dom.find("a.edit").css("display", "inline-block");
1212
dom.addClass('light');

0 commit comments

Comments
 (0)