Jquery 数据表剪掉茧隐藏输入
Jquery datatables lopping off cocoon hidden input
我有一个带有一组动态字段的应用程序。这些字段是用 cocoon 生成的,并用 jquery datatables 设置样式。为了建立任何一组字段的 id,cocoon 显然在包含字段的元素之外放置了一个隐藏输入,如下所示:
<tr class="nested-fields stockholder">
<td class="cell stockholder"></td>
<td class="cell issue_date"></td>
<td class="cell shares_issued"></td>
<td class="cell shares_repurchased"></td>
<td class="cell shares_canceled"></td>
<td class="cell shares_outstanding"></td>
<td class="cell edit"></td>
</tr>
<input id="security_stockholders_attributes_0_id" type="hidden" name="security[stockholders_attributes][0][id]" value="1">
注意输入在<tr>
之外
在最近将 datatables 升级到 1.10.9 时,我注意到 datatables 开始剪掉 cocoon 的隐藏(稍微不合适的)输入元素,导致出于显而易见的原因形成功能。
我的问题:有没有...
指定输入元素位置的方法?就目前而言,我按以下方式自定义了我的 link_to_add_association
:
<%= link_to_add_association 'Add Stockholder', security, :stockholders, :"data-association-insertion-node" => "table#captable", :"data-association-insertion-method" => "append", class: "btn btn-default add-button" %>
或
- 获取 jquery 数据table 以容忍此特定元素放置的方法?
非常感谢任何想法!
更新: 看来我可以在事后编辑 dom 并将隐藏的输入移动到 table 单元格中,所以看起来我可能有一个丑陋的解决方案 javascript 如果一切都失败了。
好的,找到了解决方法。
这个问题实际上与 cocoon 没有太大关系,因为它与 cocoon 添加的基本 fields_for
部分有关。基本上,fields_for
默认包含 id 作为隐藏 input
。但是有一个选项可以隐藏隐藏的 id 输入。我需要做的就是:
- 在我的
simple_fields_for
中添加选项 include_id: false
- 在 id 的
<td>
之一中添加隐藏输入,因此:<%= f.input :id, as: :hidden %>
可以找到更多信息 here。
我有一个带有一组动态字段的应用程序。这些字段是用 cocoon 生成的,并用 jquery datatables 设置样式。为了建立任何一组字段的 id,cocoon 显然在包含字段的元素之外放置了一个隐藏输入,如下所示:
<tr class="nested-fields stockholder">
<td class="cell stockholder"></td>
<td class="cell issue_date"></td>
<td class="cell shares_issued"></td>
<td class="cell shares_repurchased"></td>
<td class="cell shares_canceled"></td>
<td class="cell shares_outstanding"></td>
<td class="cell edit"></td>
</tr>
<input id="security_stockholders_attributes_0_id" type="hidden" name="security[stockholders_attributes][0][id]" value="1">
注意输入在<tr>
在最近将 datatables 升级到 1.10.9 时,我注意到 datatables 开始剪掉 cocoon 的隐藏(稍微不合适的)输入元素,导致出于显而易见的原因形成功能。
我的问题:有没有...
指定输入元素位置的方法?就目前而言,我按以下方式自定义了我的
link_to_add_association
:<%= link_to_add_association 'Add Stockholder', security, :stockholders, :"data-association-insertion-node" => "table#captable", :"data-association-insertion-method" => "append", class: "btn btn-default add-button" %>
或
- 获取 jquery 数据table 以容忍此特定元素放置的方法?
非常感谢任何想法!
更新: 看来我可以在事后编辑 dom 并将隐藏的输入移动到 table 单元格中,所以看起来我可能有一个丑陋的解决方案 javascript 如果一切都失败了。
好的,找到了解决方法。
这个问题实际上与 cocoon 没有太大关系,因为它与 cocoon 添加的基本 fields_for
部分有关。基本上,fields_for
默认包含 id 作为隐藏 input
。但是有一个选项可以隐藏隐藏的 id 输入。我需要做的就是:
- 在我的
simple_fields_for
中添加选项 - 在 id 的
<td>
之一中添加隐藏输入,因此:<%= f.input :id, as: :hidden %>
include_id: false
可以找到更多信息 here。