我有以下两个按钮,它们在同一页面上打开两个不同的模态:
<button class = "btn btn-primary" style = "float: left; margin-left: 15px" name = "btnDetalhes" data-toggle = "modal" data-target = "#myModal">Detalhes</button>
打开以下模式:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"><div class="modal-dialog" 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="myModalLabel">Detalhes da Conta</h4>
</div>
<div class="modal-body" style = "height: 195px">
<table class = "table table-bordered table-striped" id = "tabelaDetalhes">
<thead>
<tr>
<th width="15%">Horário Pedido</th>
<th width="45%">Nome do Produto</th>
<th width="30%">Preço (R$)</th>
</tr>
</thead>
<tbody id = "bodyTabelaDetalhes">
</tbody>
</table>
</div>
</div>
和这个按钮:
<button onclick = "abrirModalDetalhes()" data-toggle = "modal" data-target = "#modalDetalhesPedido" class = "btn btn-primary">Detalhes</button>
打开以下模式:
<div class="modal fade" id="modalDetalhesPedido" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"><div class="modal-dialog modal-lg" role="document">
<div class="modal-content" style = "height: 900px">
<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="myModalLabel" style = "font-weight: bold">Detalhes do Pedido (Nome do pedido)</h4>
</div>
<div class="modal-body" style = "height: 195px">
<p>Test</p>
</div>
</div>
嗯,事情是:第二个模式永远不会出现!
第一个模态正确打开但是当我单击按钮打开第二个模式时,它会打开一个灰色的屏幕,除非我刷新页面,否则我无法摆脱它。
我知道一些文本是葡萄牙语,但它对问题没有影响。
有人可以告诉我发生了什么事吗?谢谢!
答案 0 :(得分:1)
你的语法有点乱,这里有更新的工作代码:
<button class = "btn btn-primary" style = "float: left; margin-left: 15px" name = "btnDetalhes" data-toggle = "modal" data-target = "#myModal">Detalhes</button>
<button onclick = "abrirModalDetalhes()" data-toggle = "modal" data-target = "#modalDetalhesPedido" class = "btn btn-primary">Detalhes</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" 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="myModalLabel">Detalhes da Conta</h4>
</div>
<div class="modal-body">
<table class = "table table-bordered table-striped" id = "tabelaDetalhes">
<thead>
<tr>
<th width="15%">Horário Pedido</th>
<th width="45%">Nome do Produto</th>
<th width="30%">Preço (R$)</th>
</tr>
</thead>
<tbody id = "bodyTabelaDetalhes">
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="modalDetalhesPedido" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content" style = "height: 900px">
<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="myModalLabel" style = "font-weight: bold">Detalhes do Pedido (Nome do pedido)</h4>
</div>
<div class="modal-body" style = "height: 195px;">
<p>Test</p>
</div>
</div>
</div>
</div>