fixes duplicate id in comment form [#21]
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
jQuery ->
|
||||
|
||||
toggle_comment = (id) ->
|
||||
$("#js-comment-form-#{id}").toggle()
|
||||
toggle_comment = (id, klass) ->
|
||||
$("#js-comment-form-#{id}-#{klass}").toggle()
|
||||
|
||||
ready = ->
|
||||
$('.js-add-comment-link').click ->
|
||||
id = $(this).data().id
|
||||
toggle_comment(id)
|
||||
klass = $(this).data().klass
|
||||
toggle_comment(id, klass)
|
||||
false
|
||||
|
||||
$(document).ready(ready)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': parent.id} %>
|
||||
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': parent.id, 'klass': parent.class.to_s } %>
|
||||
|
||||
<div id="js-comment-form-<%= parent.id %>" style="display:none">
|
||||
<div id="js-comment-form-<%= parent.id %>-<%= parent.class.to_s %>" style="display:none">
|
||||
<%= form_for [@debate, Comment.new] do |f| %>
|
||||
<%= f.text_area :body %>
|
||||
<%= f.hidden_field :commentable_type, value: parent.class %>
|
||||
|
||||
@@ -48,9 +48,9 @@ feature 'Comments' do
|
||||
visit debate_path(debate)
|
||||
|
||||
click_link "Responder"
|
||||
within "#comment-#{comment.id}" do
|
||||
within "#js-comment-form-#{comment.id}-Comment" do
|
||||
fill_in 'comment_body', with: 'La semana que viene está hecho.'
|
||||
click_button 'Publicar comentario'
|
||||
click_button 'Publicar respuesta'
|
||||
end
|
||||
|
||||
expect(page).to have_content 'Comentario guardado'
|
||||
|
||||
Reference in New Issue
Block a user