I am trying to implement the idea of link_to_remove_fields from Ryan's "railscasts episode-197 ".
I seem to be having problems with the javascript file "
My application.html.erb file includes javascript: <%= javascript_include_tag "application" %>
And I add the following function to the application.js file:
function remove_fields(link) {
$(link).previous("input[type=hidden]").value = "1";
$(link).up(".fields").hide();
}
And I have the following code in the application_helper.rb file:
def link_to_remove_fields(name, f)
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
end
And in my _form I have:
<%= f.label :entry, "Descriptions" %><br />
<%= f.text_area :entry, :rows => 3 %>
<%= link_to_remove_fields "remove", f %><br />
<%= f.hidden_field :user_id, :value => current_user.id %>
When i kick off the rails server and navigate to the page i am working on, the "remove" links appear, but nothing happens when I click on it.
So I have a hunch that the javascript code is not being called?
Any ideas?
Thanks guys!
Adam