responds with ajax to comment creation [#47]

This commit is contained in:
rgarcia
2015-07-28 20:32:53 +02:00
parent 6a6804f73b
commit 3247180dfa
3 changed files with 10 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)} %>
<div id="js-comment-form-<%= dom_id(parent) %>" style="display:none">
<%= form_for [@debate, Comment.new] do |f| %>
<%= form_for [@debate, Comment.new], remote: true do |f| %>
<%= f.text_area :body %>
<%= f.hidden_field :commentable_type, value: parent.class %>
<%= f.hidden_field :commentable_id, value: parent.id %>

View File

@@ -0,0 +1,4 @@
var form = "#js-comment-form-<%= dom_id(@parent) %>"
$(form + " #comment_body").val('');
$(form).hide();
$("<%= j(render @comment) %>").insertAfter($(form));