【发布时间】:2018-09-21 17:50:49
【问题描述】:
我已经成功地向我的 rails 5 应用程序添加了一个引导模式,但是我正在尝试添加一个类似于其他 rails 表单的对话框,要求他们确认他们是否希望继续。使用此模态,我需要得到一个带有取消或继续的问题,然后将触发模态。例如,他们按下兑换,然后在显示模态之前会出现一个问题。 “您是否希望兑现您的报价。我过去曾将以下代码与 rails 一起使用,但不知道如何将其应用于 bootstrap modal。
<%= link_to theme_icon_tag("trash"), deal_path(deal), 'data-toggle':
'tooltip', title: 'Delete',data: { confirm: 'Are you sure?' }, method:
:delete, class: 'btn btn-link' %>
我的研究只展示了如何使用模态作为对话框警报本身。我必须在模态中使用模态吗?或者有没有 JS 或者 bootstrap 代码来实现这个
我的模态代码如下:
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-outline-primary btn-block" data-
toggle="modal" data-target="#redeem">Redeem Now</button>
<div id="redeem" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal">×</button>
<h4 class="modal-title"><%= @deal.deal_title %></h4>
</div>
<div class="modal-body">
<p>Your coupon code is <%= @deal.promo_code %>. You just saved
a bunch of mullah $$$$</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
【问题讨论】:
-
所以你想要一个带有兑换或取消的确认对话框,如果用户按下兑换,那么你想显示模式,对吧?
-
是的,回复上方有一条消息“您希望继续,您的报价将被兑换”
标签: ruby-on-rails twitter-bootstrap dialog bootstrap-modal