refactors duplicate form id scenario [#21]
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
jQuery ->
|
jQuery ->
|
||||||
|
|
||||||
toggle_comment = (id, klass) ->
|
toggle_comment = (id) ->
|
||||||
$("#js-comment-form-#{id}-#{klass}").toggle()
|
$("#js-comment-form-#{id}").toggle()
|
||||||
|
|
||||||
ready = ->
|
ready = ->
|
||||||
$('.js-add-comment-link').click ->
|
$('.js-add-comment-link').click ->
|
||||||
id = $(this).data().id
|
id = $(this).data().id
|
||||||
klass = $(this).data().klass
|
toggle_comment(id)
|
||||||
toggle_comment(id, klass)
|
|
||||||
false
|
false
|
||||||
|
|
||||||
$(document).ready(ready)
|
$(document).ready(ready)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': parent.id, 'klass': parent.class.to_s } %>
|
<%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)} %>
|
||||||
|
|
||||||
<div id="js-comment-form-<%= parent.id %>-<%= parent.class.to_s %>" style="display:none">
|
<div id="js-comment-form-<%= dom_id(parent) %>" 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 %>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ feature 'Comments' do
|
|||||||
visit debate_path(debate)
|
visit debate_path(debate)
|
||||||
|
|
||||||
click_link "Responder"
|
click_link "Responder"
|
||||||
within "#js-comment-form-#{comment.id}-Comment" do
|
within "#js-comment-form-comment_#{comment.id}" do
|
||||||
fill_in 'comment_body', with: 'La semana que viene está hecho.'
|
fill_in 'comment_body', with: 'La semana que viene está hecho.'
|
||||||
click_button 'Publicar respuesta'
|
click_button 'Publicar respuesta'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user