Forum: Ruby on Rails Need Help with Rails 2.3 Four Level Nested Form Javascript Function

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D0fb72721fb02f3aa895836faeccc1fe?d=identicon&s=25 Todd (Guest)
on 2009-04-17 12:11
(Received via mailing list)
Hi I'm using Alloy's Complex Form Example found here(
alloy/complex-form-examples/tree/master). The example he provides is a
two level hierarchy and I'm trying to expand it to four.

He has javascript functions for adding nested items. Can someone show
me how to expand for four nested layers?

'.add_nested_item': function(e){
   el = Event.findElement(e);
   template = eval(el.href.replace(/.*#/, ''))
     bottom: replace_ids(template)
 '.add_nested_item_lvl2': function(e){
   el = Event.findElement(e);
   elements = el.rel.match(/(\w+)/g)
   parent = '.'+elements[0]
   child = '.'+elements[1]

   child_container = el.up(parent).down(child)
   parent_object_id = el.up(parent).down('input').name.match(/.*\[(\d+)

   template = eval(el.href.replace(/.*#/, ''))

   template = template.replace(/(attributes[_\]\[]+)\d+/g,

   // console.log(template)
     bottom: replace_ids(template)

Thanks anybody who can help!  I'm really trying to learn here!

I've posted this question on StackOverflow if anyone wants to answer
it there.
This topic is locked and can not be replied to.