我有一个Bootstrap Modal来选择事件。如果用户单击X按钮或在模式之外,我希望将他们发送到默认事件。如何捕获这些事件?
这是我的HTML代码:
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content event-selector">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<center><h1 class="modal-title event-selector-text">Select an Event</h1><center>
</div>
<div class="container"></div>
<div class="modal-body">
<div class="event-banner">
<a href="/?event=1">
<img src="<?php echo IMAGES_EVENT1_LOGO; ?>" width="100%">
</a>
</div>
<div class="event-banner">
<a href="/?event=2">
<img src="<?php echo IMAGES_EVENT2_LOGO; ?>" width="100%">
</a>
</div>
</div>
</div>
</div>
</div>
发布于 2017-07-20 17:51:06
虽然在另一个堆栈溢出问题Bind a function to Twitter Bootstrap Modal Close中得到了回答,但为了视觉上的感受,这里有更详细的答案。
来源:http://getbootstrap.com/javascript/#modals-events
发布于 2017-03-12 01:04:04
我试着使用它,但没有起作用,我猜它只是一个模态版本。
虽然,它是这样工作的:
$("#myModal").on("hide.bs.modal", function () {
// put your default event here
});
只是为了更新答案=)
发布于 2020-06-07 23:42:21
这对我很有效,任何人都可以试一下。
$("#myModal").on("hidden.bs.modal", function () {
for (instance in CKEDITOR.instances)
CKEDITOR.instances[instance].destroy();
$('#myModal .modal-body').html('');
});
您可以在模态窗口中打开ckEditor
https://stackoverflow.com/questions/30298041
复制相似问题