3
I want to run the modal only if there is the call. Because it is taking too long to open the page.
Below follows the modal used:
<div class="modal fade" id="m_modal<?php echo $count ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="m-portlet m-portlet--full-height ">
<div class="m-portlet__head">
<div class="m-portlet__head-caption">
<div class="m-portlet__head-title">
<h3 class="m-portlet__head-text">
Produtos Licenciados
</h3>
</div>
</div>
<div class="m-portlet__head-tools">
</div>
</div>
<div class="m-portlet__body">
<div class="m-widget6">
<div class="m-widget6__head">
<div class="m-widget6__item">
<span class="m-widget6__caption">
Nº do Produto
</span>
<span class="m-widget6__caption">
Validade
</span>
<span class="m-widget6__caption">
Tipo
</span>
<span class="m-widget6__caption m--align-right">
Valor
</span>
</div>
</div>
<div class="m-widget6__body">
<?php
$comprador = $row['cod_comprador'];
$sqlrec = $db->prepare("SELECT pro.numero_produto, pro.validade, pro.tipo_produto, pro.valor_produto FROM prouto pro where rec.cod_comprador = '$comprador' ORDER BY pro.validade desc");
$sqlrec->execute(); $arec = 0 ;
while($rowrec=$sqlrec->fetch(PDO:: FETCH_ASSOC)){
$arec++; ?>
<div class="m-widget6__item">
<span class="m-widget6__text">
<? echo $rowrec['numero_produto']?>
</span>
<span class="m-widget6__text">
<?php echo date('d/m/Y', strtotime($rowrec['validade']));?>
</span>
<?php
switch ($rowrec['tipo_produto']) {
case '1':
echo "<span class='m-widget6__text'>Avulsa</span>";
break;
case '2':
echo "<span class='m-widget6__text'>Mensal</span>";
break;
}
?>
<span class="m-widget6__text m--align-right m--font-boldest m--font-brand">
R$<? echo str_replace('.', ',', $rowrec['valor_produto'])?>
</span>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Here I call the Modal
<a href="javascript:;" class="btn btn-secondary m-btn m-btn--icon m-btn--icon-only" data-toggle="modal" data-target="#m_modal<?php echo $count++ ?>">
<i class="la la-barcode"></i>
</a>
Utilize Ajax. Every time you want to open determined modal, just make a request for a new page to capture, format and return the modal with the information (all this via JS).
– Valdeir Psr
Right. You have some example ?
– Robson Freitas
There are several modals on the page?
– Sam
where this variable comes from
$count
?– user60252
So. I’m using a datatable with 3,000 records. for each row it has the button that calls a modal with information from another table, which has link. It works perfectly in the current mode. only it takes 17 seconds to open the page, as you are also reading the sql of this modal. Since it is not displayed at the beginning, it is only to show the data when clicking the button. I made some examples, but it did not work.
– Robson Freitas
This variable use within the tbody If I do not put this info, it does not present the data per line. That is, the modal comes with the same information on all lines.
– Robson Freitas
@Robsonfreitas On the page https://cursos.alura.com.br/forum/topico-load-modal-ajax-47058 (Rodrigo Adolfo de Paula’s reply) he posted a nice example, but you can use a library if you can’t create the function. http://jquerymodal.com/#example-4
– Valdeir Psr
Okay, I’ll take a look.
– Robson Freitas
So each button has a modal?
– Sam
I fear as I send you an example by link ?
– Robson Freitas
It’s not necessary.
– Sam
http://riftec.com.br/ranking/temp.php In the action column, the left button. Limited to 5 records. but that would be the password.
– Robson Freitas