Twitter bootstrap 为什么引导切换按钮只能在模式对话框中第一次单击?
引导切换按钮仅在第二次关闭和打开后第一次工作切换按钮无法切换。它在第三次打开后再次工作Twitter bootstrap 为什么引导切换按钮只能在模式对话框中第一次单击?,twitter-bootstrap,toggle,Twitter Bootstrap,Toggle,引导切换按钮仅在第二次关闭和打开后第一次工作切换按钮无法切换。它在第三次打开后再次工作 <input checked data-toggle="toggle" type="checkbox"> 代码怎么了?有解决办法吗 <button type="button" id="mymodal" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal1"> 发射模式1 &时
<input checked data-toggle="toggle" type="checkbox">
代码怎么了?有解决办法吗
<button type="button" id="mymodal" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal1">
发射模式1
&时代;
模式1标题
接近
保存更改
以下是解决方案:
<button type="button" id="mymodal" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal1">Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal1" 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 1 title</h4>
</div>
<div class="modal-body">
<div>
<input checked type="checkbox" id="toggle-check" data-toggle="toggle">
<span class="checked">Value 1</span>
<span class="unchecked">Value 0</span>
</div>
</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>
这里是预览链接:
要在模式中重新初始化引导切换插件,请添加以下代码:
$('.modal').on('shown.bs.modal', function (e) {
$('#toggle-check').bootstrapToggle();
})
以下是解决方案:
<button type="button" id="mymodal" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal1">Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal1" 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 1 title</h4>
</div>
<div class="modal-body">
<div>
<input checked type="checkbox" id="toggle-check" data-toggle="toggle">
<span class="checked">Value 1</span>
<span class="unchecked">Value 0</span>
</div>
</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>
这里是预览链接:
要在模式中重新初始化引导切换插件,请添加以下代码:
$('.modal').on('shown.bs.modal', function (e) {
$('#toggle-check').bootstrapToggle();
})
请在codepen/jsfiddle上分享你的问题代码好吗?@ZahidulIslamRuhel jsfiddle没有问题……你能添加完整的代码吗?here@ZahidulIslamRuhel这个有什么漏洞吗?因为在使用外部模态对话框时,切换按钮在第一次关闭模态对话框后无法切换。请在codepen/jsfiddle上分享您的问题代码好吗?@ZahidulIslamRuhel jsfiddle没有问题……您能添加完整的代码吗?here@ZahidulIslamRuhel这个有什么漏洞吗?因为在使用外部模态对话框时,切换按钮没有问题,所以在第一次关闭模态对话框后,切换按钮无法切换。