Skip to content

Loading…

Added button to discard a reply to a comment. #55

Closed
wants to merge 1 commit into from

1 participant

@sindrenm

Hey!

I've created a button on your New Comment form which is visible only when the form is being used for replying to another comment. The button unobtrusively removes the form from the page (actually removes it from the DOM, it's not just hiding it). It's a small commit, but a feature I think should be available in those cases where you figure you really don't want to reply anyway, when you clicked the wrong reply link or whatever.

Hope you find it useful. :-)

@sindrenm

Closing due to inactivity.

@sindrenm sindrenm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2012
  1. @sindrenm
Showing with 10 additions and 0 deletions.
  1. +3 −0 app/views/comments/_form.html.erb
  2. +7 −0 public/javascripts/application.js
View
3 app/views/comments/_form.html.erb
@@ -72,6 +72,9 @@ puts "code block"
<% end %>
<div class="actions">
<%= f.submit(@comment.new_record? ? "Post Comment" : "Update Comment") %>
+ <% if params[:controller] == "comments" %>
+ <%= link_to "Discard", "#", :class => "remove_comment" %>
+ <% end %>
</div>
<% end %>
</div>
View
7 public/javascripts/application.js
@@ -60,5 +60,12 @@ $(function() {
$(this).children(".clippy_label").text("copied");
}
});
+
+ // Remove reply-to-comment field
+ $(".nested_comments").delegate(".remove_comment", "click", function() {
+ $(this).closest("div#new_comment").remove();
+
+ return false;
+ });
}
});
Something went wrong with that request. Please try again.