我正在尝试关闭第一个模态然后显示另一个带有表单的模态。 我尝试了不同的解决方案。它没有关闭第一个模态但显示第一个模态背后的第二个模态。
以下是代码:
app.get('/block_name', function (req,res){
//var id= req.body.site;
var sql='SELECT `block_name`,`block_id` FROM `tbl_block` ';
connection.query(sql,function(err, result) {
if (err) throw err;
res.json(result);
});
});
答案 0 :(得分:1)
如果没有看到具体的代码,很难给出准确的答案。但是,从Bootstrap文档中,您可以隐藏模态,如下所示:
$('#myModal').modal('hide');
然后,一旦它被隐藏,显示另一个模态:
$('#myModal').on('hidden', function () {
// Load up a new modal...
$('#myModalNew').modal('show')
});
答案 1 :(得分:1)
我希望你能实现这个目标。
尝试全屏运行代码段以查看其是否有效 -
$(document).ready(function(){
$("#test1").click(function(){
$('.bs-example-modal-lg').modal('show');
$('.bs-example-modal-sm').modal('hide');
});
$("#test2").click(function(){
$('.bs-example-modal-lg').modal('hide');
$('.bs-example-modal-sm').modal('show');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<hr/>
<hr/>
<!-- 1 modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Show Modal1</button>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg" 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="exampleModalLabel">Modal 1</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="recipient-name" class="control-label">Recipient:</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="message-text" class="control-label">Message:</label>
<textarea class="form-control" id="message-text"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Send message</button>
<button type="button" class="btn btn-primary" id="test2">Show Second/ Hide First</button>
</div>
</div>
</div>
</div>
<!-- 2 modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Show modal2</button>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm" 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="exampleModalLabel">Modal 2</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="recipient-name" class="control-label">Recipient:</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="message-text" class="control-label">Message:</label>
<textarea class="form-control" id="message-text"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Send message</button>
<button type="button" class="btn btn-primary" id="test1">Show First/ Hide Second</button>
</div>
</div>
</div>
</div>
答案 2 :(得分:0)
你可以使用下面的代码隐藏其他,隐藏其他模态然后显示第二个
$('#WEITER').click(function() {
$('#myModal5').modal('hide');
$('#myModal55').modal('show');
});
答案 3 :(得分:0)
使用Bootstrap模式
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal1">Open Modal</button>
<!-- Modal 1-->
<div class="modal fade" id="myModal1" 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>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal2">open new modal</button>
</div>
</div>
</div>
</div>
<!-- Modal 2-->
<div class="modal fade" id="myModal2" 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>