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,3 +1,6 @@
|
|||||||
|
<%= 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| %>
|
<%= form_for [@debate, Comment.new] do |f| %>
|
||||||
<%= f.text_area :body %>
|
<%= f.text_area :body %>
|
||||||
<%= f.hidden_field :commentable_type, value: parent.class %>
|
<%= f.hidden_field :commentable_type, value: parent.class %>
|
||||||
@@ -5,3 +8,4 @@
|
|||||||
|
|
||||||
<%= f.submit 'Publicar comentario' %>
|
<%= f.submit 'Publicar comentario' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user