ここにある Alloy の Complex Form Example を使用しています。彼が提供する例は 2 レベルの階層で、私はそれを 4 に拡張しようとしています。
彼は、ネストされたアイテムを追加するための JavaScript 関数を持っています。ネストされた 4 つのレイヤーを展開する方法は?
'.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)
});
}