adds hide/show behaviour to comment forms
This commit is contained in:
9
app/assets/javascripts/comments.js.coffee
Normal file
9
app/assets/javascripts/comments.js.coffee
Normal file
@@ -0,0 +1,9 @@
|
||||
jQuery ->
|
||||
|
||||
toggle_comment = (id) ->
|
||||
$("#js-comment-form-#{id}").toggle()
|
||||
|
||||
$('.js-add-comment-link').click ->
|
||||
id = $(this).data().id
|
||||
toggle_comment(id)
|
||||
false
|
||||
@@ -1,7 +1,11 @@
|
||||
<%= form_for [@debate, Comment.new] do |f| %>
|
||||
<%= link_to "Comentar", "", class: "js-add-comment-link", data: {'id': parent.id} %>
|
||||
|
||||
<div id="js-comment-form-<%= parent.id %>" style="display:none">
|
||||
<%= form_for [@debate, Comment.new] do |f| %>
|
||||
<%= f.text_area :body %>
|
||||
<%= f.hidden_field :commentable_type, value: parent.class %>
|
||||
<%= f.hidden_field :commentable_id, value: parent.id %>
|
||||
|
||||
<%= f.submit 'Publicar comentario' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user