합금의 복잡한 폼 예제를 사용하고 있습니다. here입니다. 그가 제공하는 예제는 2 수준의 계층이며 4로 확장하려고합니다.레일 2.3 네 레벨 중첩 된 폼 Javascript 함수
그는 중첩 된 항목을 추가하기위한 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)
});
}
앱을 작성해 주셔서 감사합니다. 내 질문을 업데이트했습니다. – Todd