我有一个Bootstrap模式,当单击此链接时会触发:
<a class="plus" href="javascript:;" data-toggle="modal" data-target="#myModal"> </a>
然后我把这个放在我的
_footer.html.erb
<%= render 'shared/tag_users_modal' %>
然后有了这个标准的Bootstrap模式:
<!-- Modal -->
<div class="modal tagging fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Tag User</h4>
</div>
<div class="modal-body">
<%= simple_form_for @node, url: add_tagged_user_node_path(@node), method: :post do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input_field :user, label: "Users", collection: @users, as: :check_boxes, checked: @node.user_tags %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
这行不通,因为
@node
为零-即未通过。我不能从我的
_footer
分部,所以我希望能够在模态的原始执行中传递它。
我该怎么做?或者我如何以另一种方式做到这一点?
编辑1
为了添加更多上下文,调用Bootstrap Modal的初始链接实际上位于另一个局部变量
node
也传递给了它。这个叫做这样:
<%=渲染部分:“shared/box”,局部变量:{node:node}%>
但我需要继续执行模式,只有在第一次单击切换链接后才启动
shared/box
.
总而言之:
-
/shared/box
分部具有激发BS模态的原始链接。
-
/shared/footer' contains a render of another partial
标记用户模式
.
-
/共享/标记用户模式
contains the modal, but I need the
@节点
object passed to it and the
add_tagged_user_node_path`工作。
现在它没有通过,因为我想不出一种方法来获得原件
node: node
链中的第三部分。