我有一个看起来像这样的结构:
修改
我的索引显示如下:
%span.right
= render "modifications/form", modification: modification
Form和Miniform几乎完全相同:
.modification-forms
- if can? :reject, modification.model
= form_tag modification_rejections_url, class: "inline", remote: true do |f|
= hidden_field_tag :id, modification.model.id
= submit_button "Reject", class: 'btn btn-danger'
- if can? :approve, modification.model
= form_tag modification_approvals_url, class: "inline", remote: true do |f|
= hidden_field_tag :id, modification.model.id
= submit_button "Approve" , class: 'btn btn-success'
vs miniform
.modification-device-forms
- if can? :reject, modification.model
= form_tag modification_rejections_url, class: "inline", remote: true do |f|
= hidden_field_tag :id, modification.model.id
= submit_button "<i class='icon-remove'> </i>".html_safe
- if can? :approve, modification.model
= form_tag modification_approvals_url, class: "inline", remote: true do |f|
= hidden_field_tag :id, modification.model.id
= submit_button "<i class='icon-ok'> </i>".html_safe
当我渲染_form部分时,ajax会执行你期望的方式。单击按钮后,该行将消失。
然而,当我交换miniform时,它不再有效。 ajax运行,但它不会删除该行。
我认为这是轨道惯例混淆,但我对rails魔法不太好,并且不知道从哪里开始解密这个。
有没有办法让这项工作?