我正在使用带有简单开/关选项的Bootstrap Switch 。on
一旦用户从tooff
或 from off
to更改,如何显示 Bootstrap Modal 要求确认on
?
示例 1 - 用户点击切换on
。
模态: Are you sure you want to switch on?
示例 2 - 用户点击切换off
。
模态: Are you sure you want to switch off?
我可以在这个jsfiddle上设置模式,但如果用户直接点击蓝色或灰色,它就不起作用。
<div data-toggle="modal" data-target="#showModal">
Change status:
<input type="checkbox" class="switch" checked />
</div>
<!-- Modal -->
<div class="modal fade" id="showModal" 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">Modal title</h4>
</div>
<div class="modal-body">
This is the modal
</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>