diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 7cc087e..8f05e90 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -313,14 +313,14 @@ $(document).ready(function() { }); $(document).on("click", "button.comment-cancel", function() { - var comment = $(this).closest(".comment[data-shortid]"); - if (comment.length) { - $.get("/comments/" + comment.attr("data-shortid"), - function(data) { - comment.html($.parseHTML(data)); + var comment = $(this).closest(".comment"); + var comment_id = comment.attr("data-shortid"); + if (comment_id != null && comment_id !== '') { + $.get("/comments/" + comment_id, function(data) { + comment.replaceWith($.parseHTML(data)); }); } else { - $(this).closest(".comment").remove(); + comment.remove(); } }); diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index a196292..724b639 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -63,8 +63,7 @@ class CommentsController < ApplicationController end render :partial => "comment", :layout => false, - :content_type => "text/html", :locals => { :comment => comment, - :cancellable => true } + :content_type => "text/html", :locals => { :comment => comment } end def edit @@ -73,8 +72,7 @@ class CommentsController < ApplicationController end render :partial => "commentbox", :layout => false, - :content_type => "text/html", :locals => { :comment => comment, - :cancellable => true } + :content_type => "text/html", :locals => { :comment => comment } end def reply @@ -87,8 +85,7 @@ class CommentsController < ApplicationController comment.parent_comment = parent_comment render :partial => "commentbox", :layout => false, - :content_type => "text/html", :locals => { :comment => comment, - :cancellable => true } + :content_type => "text/html", :locals => { :comment => comment } end def delete diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 350e525..c9cf25f 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,5 +1,5 @@ - -
<%= comment.highlighted ? "highlighted" : "" %> @@ -24,6 +24,8 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ? <% end %>