allow_destroy =>真的不起作用 在视图中:
% fieldset.fieldset-border
% br
. form-group
. col-sm-offset-1.col-sm-10
= P.input: first_name, label: 'Name', class: 'form-control'
= P.input: surname, label: 'Name', class: 'form-control'
= P.input: patronymic, label: 'First Name', class: 'form-control'
= P.input: job_position, label: 'Title', class: 'form-control'
= P.hidden_field: _destroy
= Link_to "Delete", '#', class: "remove_fields"
% br
% br
脚本
jQuery ->
$ ('form'). on 'click', '. remove_fields', (event) ->
$ (this). prev ('input [type = hidden]'). val ('1 ')
$ (this). closest ('fieldset'). hide ()
event.preventDefault ()
$ ('form'). on 'click', '. add_fields', (event) ->
time = new Date (). getTime ()
regexp = new RegExp ($ (this). data ('id'), 'g')
$ (this). before ($ (this). data ('fields'). replace (regexp, time))
event.preventDefault ()
模型
class
...
accepts_nested_attributes_for: people,: allow_destroy => true
accepts_nested_attributes_for: legal_entities,: allow_destroy => true
end
当尝试otredktirovat浏览器端yavaskrita隐藏如何 但不删除和复制记录。
Why doesn't accepts_nested_attributes_for allow_destroy not work?
通过截屏视频制作 http://railscasts.com/episodes/197-nested-model-form-part-2 http://railscasts.com/episodes/196-nested-model-form-part-1
请告诉我如何打击这个。