要删除rails中的记录,我正在使用此代码 <%= link_to"关闭#{user.name}' s",light_path(id:light),方法:: delete,data:{confirm:'你确定吗? ?' }%> 结果,我得到像
这样的对话框有没有办法自定义确认对话框的默认视图?
答案 0 :(得分:5)
您可以使用bootstrap模式对话框,如下所示:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<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">Delete Confirmation</h4>
</div>
<div class="modal-body">
Are you sure about closing Ellen's lightbox..
<%= link_to "Yes", light_path(id: light), method: :delete %>/
<%= link_to "No", "javascript:void(0)",'data-dismiss': "modal" %>
</div>
</div>
</div>
</div>
并将您的初始链接更改为:
<%= link_to "close #{user.name}'s light", "javascript:void(0)", 'data-target': "#myModal", 'data-toggle': "modal" %>
我希望这对你有帮助。