【发布时间】:2009-04-12 10:29:10
【问题描述】:
我正在使用 here 找到的 Alloy 的复杂形式示例。他提供的示例是两级层次结构,我正在尝试将其扩展到四级。
他有用于添加嵌套项的 javascript 函数。四层嵌套如何展开?
'.add_nested_item': function(e){
el = Event.findElement(e);
template = eval(el.href.replace(/.*#/, ''))
$(el.rel).insert({
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+)\]/)[1]
template = eval(el.href.replace(/.*#/, ''))
template = template.replace(/(attributes[_\]\[]+)\d+/g, "$1"+parent_object_id)
// console.log(template)
child_container.insert({
bottom: replace_ids(template)
});
}
【问题讨论】:
标签: ruby-on-rails ruby forms nested-forms