fxposter/nested_form — Issue #1: 'add_fields' is undefined
Author: hopewise
Created: 2011-11-02 05:33:36+00:00
State: open

Hello,

I have followed your instructions, but I still have this error: 'add_fields' is undefined when I click on add_item

it seems that javascript add_fields in nested_form.js can't be reached ??

here is the result at my application layout:

here is the code at application_helper

module ApplicationHelper
def link_to_remove_fields(name, f)
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
end

def link_to_add_fields(name, f, association)
new_object = f.object.class.reflect_on_association(association).klass.new
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render(association.to_s.singularize + "_fields", :f => builder)
end
link_to_function(name, "addFields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")
end
end