Gabriel Augusto Gabriel Augusto - 3 months ago 9
CSS Question

One modal is opening and the other gives a grey screen

I have the following two buttons, which opens two different modals on the same page:

<button class = "btn btn-primary" style = "float: left; margin-left: 15px" name = "btnDetalhes" data-toggle = "modal" data-target = "#myModal">Detalhes</button>


opens the following 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">&times;</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>




and this button:

<button onclick = "abrirModalDetalhes()" data-toggle = "modal" data-target = "#modalDetalhesPedido" class = "btn btn-primary">Detalhes</button>


opens the following modal:

<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">&times;</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>




Well, the things is: THE SECOND MODAL NEVER SHOWS UP!

The first modal opens correctly but when I click the button to open the second one, it opens a grey screen and I can't get out of it unless I refresh the page.

I know some Texts are in Portuguese, but it doesn't make difference on the problem.

Can someone please tell me what's going on? Thanks!

Answer

Your syntax is a bit messed up, here is updated working code:

<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">&times;</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">&times;</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>

JSFiddle DEMO