I'm trying to create a form with one parent and multiple children,
each with multiple grandchildren based on the pastie that pimpmaster
posted (
http://pastie.textmate.org/163163) and I'm having a couple of
issues. Hoping someone can shed some light on this.
One problem is getting the grandchildren to add to the appropriate
child DIV tag since the names are all the same. For example, within
the parent form I have:
id=children
class=child
id=grand_children
class=grand_child
class=grand_child
< %= f.add_associated_link('Add Grandchild',
child.grand_children.build) % >
class=child
id=grand_children
class=grand_child
class=grand_child
< %= f.add_associated_link('Add Grandchild',
child.grand_children.build) % >
There are two sets of grandchildren, one for each child. However the
add_associated_link for both sets just adds to the first
"grand_children" DIV. The only way I could think of to get around
this was to add an associated
child.id to the grand_children class
name. So it becomes something like:
< %= f.add_associated_link('Add Grandchild',
child.grand_children.build, {:container => "grand_children" +
child.id.to_s}) % >
This works fine so for for adding grandchildren to the appropriate DIV
but I'm not sure if this is the best way to do this and if it'll even
work once I start dynamically adding more children using the
add_associated_link. I haven't been able to test that yet...which
brings me to the second issue.
Once I added grandchildren into the mix, I get a "missing ] after
element list" javascript error when trying to add a child. This only
occurs when the child partial contains the add_associated_link for
adding grandchildren.
From what I can tell I'm using version 0.2.1.
Can someone who's gotten this working help?