我正在尝试使 actiontext blob 触发模式,但它不起作用。
action_storage/blobs/_blob.rb
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
<% if blob.representable? %>
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 500, 500 ] : [ 500, 500 ]) %>
<% end %>
<figcaption class="attachment__caption">
<% if caption = blob.try(:caption) %>
<%= caption %>
<% end %>
</figcaption>
</figure>
My modal
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
我试过像这样包装按钮或标签
<% if blob.representable? %>
<a href="#exampleModalCenter" data-toggle="modal" data-target="#exampleModalCenter">
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 500, 500 ] : [ 500, 500 ]) %>
</a>
<% end %>
或者
<button type="button" class="btn" data-toggle="modal" data-target="#exampleModalCenter">
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 500, 500 ] : [ 500, 500 ]) %>
</button>
或者
<%= link_to 'Click Here', "#", data: {toggle: "modal", target: "#modal"} do %>
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 200, 200 ] : [ 200, 200 ]) %>
<% end %>
还有更多但没有触发模式
我希望用户能够单击附件并在模式中获得更大的视图。
我的应用程序中有其他模式可以正常工作。我尝试了多种不同的方法,但我得到的最接近的是链接只是刷新了页面。我认为可以通过这个部分使图像触发模态?
有任何想法吗?泰