i am making a simple app that should remove fields dynamically using rails 4 , i am doing that basically bu following rails cast tutorial , but its in rails 3 , i manged to solve most of the problems thanks God but i am stuck in this one ,the remove link appears correctly it just don't work !!!
when i go to localhost:3000/survey/new
every thing looks ok and the remove links are as it should be
when i click remove the url just change from localhost:3000/survey/new
to localhost:3000/survey/new#
here is a part of my code that i think its related to the remove link
#_form.html.erb
<%= f.fields_for :questions do |ff| %>
<div class="field">
<%= render 'question_fields', :f => ff %>
</div>
<% end %>
#_question_field.html.erb
<div class="field">
<p>
<%= f.label :content , "question"%><br>
<%= f.text_area :content %>
<%= link_to_remove_fields "remove", f %>
</p>
</div>
module ApplicationHelper
def link_to_remove_fields(name, f)
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
end
end
#application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
function remove_fields(link) {
$(link).previous("input[type=hidden]").value = "1";
$(link).parent(".fields").hide();
}
any help as i have no clue what to do or what is missing