Bootstrap关闭模式不起作用
我这里有两个用于关闭模态的按钮。第一个是关闭图标,另一个是取消按钮,都使用数据关闭来关闭模态。但是,它们都不起作用。我使用相同的代码为另一个模态,他们工作正常。任何猜测?
I have two button here that are being used to close the modal. The first is the close icon and the other one is cancel button, both use data-dismiss to close the modal. However, both of them are not working. I am using the same code for another modal and there they are working fine. Any guesses?
<div id="timeSelectModal{{entry.position - 1}}" style="display: none" class="modal">
<div class="modal-dialog">
<div id="timeSelectModalContent" class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<label>
<input id="checkbox8pm{{entry.position - 1}}" type="checkbox" value="first_checkbox">
<label class="checkbox-label">Thursday, 08:00 pm.</label>
</label>
<br>
<label>
<input id="checkbox9pm{{entry.position - 1}}" type="checkbox" value="second_checkbox">
<label class="checkbox-label">Thursday, 09:30 pm.</label>
</label>
<div id="time-modal-footer" class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success" id="timeSaveButton{{entry.position - 1}}" v-on:click="setTime(entry.position - 1)">Save</button>
</div>
</div>
</div>
</div>
很老的话题但它仍然首先出现在人们面前搜索这个问题,可能是由于他们造成了同样的简单错误,我做的是未能确保模态div不在主体div之外。要使用Material Kit作为示例,您应该仔细检查目标#myModaldiv是否在主容器的结束div标记之外。
Very old topic but it still shows up first for people searching this problem, likely caused by them making the same simple mistake I did which was failing to ensure that the modal div was outside of the main body div from which it was launched. To use the Material Kit as an example, you should double check that the target "#myModal" div is outside the closing div tag for your main container.
<div class="main main-raised">
<div class="container">
<!-- modals -->
<div class="row" id="modals">
<div class="col-md-6">
<button class="btn btn-primary btn-raised btn-round" data-toggle="modal" data-target="#myModal">
Classic modal
</button>
</div>
</div>
<!-- end modals -->
</div>
</div>
<!-- Classic Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<i class="material-icons">clear</i>
</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>Hey hey</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-simple">Nice Button</button>
<button type="button" class="btn btn-danger btn-simple" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- End Modal -->