[英]Modal Close/Open
Have the following code to close and modal and open a second modal. 使用以下代码关闭模式并打开第二个模式。 Always encounter the same problem can close one but not open the second or if I change the order I can open one and not close the other.
总是遇到相同的问题可以关闭一个但不能打开第二个,或者如果我更改顺序,我可以打开一个而不关闭另一个。 (think I have tried a 101 versions).
(认为我尝试了101版本)。 If any one can help.
如果有人可以帮助您。
<a class="btn button_replace" href="#" id="close_open">
Replace Entry <i class="icon-exchange"></i>
</a>
<script type="text/javascript">
$("#close_open").click(function() {
$("#viewfilm").modal('hide');
$("#upfilm").modal({show:true});
});
</script>
You need to use 您需要使用
$("#upfilm").modal("show");
instead of 代替
$("#upfilm").modal({show:true});
Try waiting for closing to finish 尝试等待关闭完成
$("#close_open").click(function() {
$("#viewfilm").modal('hide');
});
$('#viewfilm').on('hidden.bs.modal', function () {
$("#upfilm").modal({show:true});
});
or for older bootstrap 或较旧的引导程序
$('#viewfilm').on('hidden', function () {
$("#upfilm").modal({show:true});
});
You need to change: 您需要更改:
$('#upfilm').modal({
show: true
});
to: 至:
$('#upfilm').modal('show');
Use attribute data-dimiss 使用属性数据分配
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Activate Modal with JavaScript</h2>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" id="myBtn">Open Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$("#myBtn").click(function(){
$("#myModal").modal();
});
});
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.