I am getting this error when trying to use the remove link explained in the Railscast:
error: $(link).previous("input[type=hidden]") is undefined remove_fields()applic...1065175 (line 6) function onclick(event) { remove_fields(this); return false; }()1 (line 2) [Break on this error] $(link).previous("input[type=hidden]").value = "1";
in the view file I have :
<% echantillon_form.fields_for :treatments do |builder| %> <%= render "treatment", :f => builder %> <% end %>
in the partial I have :
<p class = "treatmentfields">
<tr> <td class ="name"> type d'examen: </td><td></td><td><%= f.text_field :treatmenttype %></td> <td></td> </tr>
<tr> <td class ="name"> commentaires sur la preparation : </
<td></td><td><%= f.text_field :preparation %></td>
<td></td> </tr>
<%= f.hidden_field :_destroy %>
<tr><td><%= link_to_function "remove", "remove_fields(this)" %></td></tr>
</p>
and in the appliction.js file I have:
function remove_fields(link) {
$(link).previous("input[type=hidden]").value = "1"; $(link).up(".treatmentfields").hide();
}