"Test of nested Boostrap modals"
Bootstrap 3.3.0 Snippet by cdenby

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<h2>Testing to see if Bootstrap 3 will handle modals called from modals</h2>
</div>
<snap class="lnklbl alert-danger" onClick="CreateFirstModal();">Click me to open the first modal</snap>
<div id="modal1holder">
<div class="modal fade" id="myfirstmodal">
<div class="modal-dialog" role="document" id="myfirstmodalchild">
<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">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
<span class="lnklbl alert-danger" onclick="OpenSecondModal();">Click me for nested second modal</span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
<div id="modal2holder">
<div class="modal fade" id="mysecondmodal">
<div class="modal-dialog" role="document" id="myfirstmodalchild">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
h2 {background-color: lightblue;}
.lnklbl {cursor:pointer;}
#modal1holderX {display: none;}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
function CreateFirstModal(){
$($("#modal1holder").html()).modal();
}
function OpenSecondModal(){
$($("#modal2holder").html()).modal();
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: