remove_fields & add field link not working on nested form in rails 3.0.9

前端 未结 2 999
夕颜
夕颜 2021-01-21 06:04

I am following Ryan bates neted_forms episode 1 & 2 from rails casts, I have already implemented the nested-forms functionality in one of my project before & it\'s worki

相关标签:
2条回答
  • 2021-01-21 06:39

    I was having problems with deletion until I added :allow_destroy => true on my parent model.

    0 讨论(0)
  • 2021-01-21 06:53

    Put this js in application.js file

    function remove_fields(link) {
    $(link).prev("input[type=hidden]").val("1");
    $(link).closest(".fields").hide(); }

    function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g"); $(link).parent().before(content.replace(regexp, new_id)); }

    0 讨论(0)
提交回复
热议问题