Recently I've come across this bug that I simply don't know how to fix.
When I click on the button "Ver Receita" it doesn't show anything, but if I click again the modal opens. I think that the problem is in the fact that the modal is in an external file (Due to the fact that the modal is dynamic).
The HTML with the button
<button type="button"
class="btn btn-success text-center mb-1"
data-toggle="modal"
data-target="#receita"
onclick="verReceita(<?php echo $registo['id'];?>)">
Ver Receita
</button>
This Button is triggering the div inside verReceita.php to show up
<div class="modal fade" id="receita">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h1 class="page-header text-center">Detalhes da Receita</h1>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<table class="table table-striped table-bordered border border-dark">
<tbody>
</tbody>
</table>
<h2>Ingredientes</h2>
<p>Quero que aqui apareçam os ingredientes associados à receita</p>
</div>
<div class="modal-footer">
<button class="btn btn-success" type="button" class="btn pull-left" data-dismiss="modal">Cancelar</a></button>
</div>
</div>
</div>
</div>
verReceita.php
function verReceita(id){
var numReceita = id;
$.post('verReceita.php',{postnumReceita: numReceita},
function(data){
$('#result').html(data);
});
}
My verReceita.php makes a AJAX request and sends the parameter to the external verReceita.php
Any suggestion on fixing this two-click issue?