Call a modal using function

0

I have a table, which lists driver data, which when clicking on a table column triggers a modal.

But I want, when clicking, to call a function, which returns the modal, and not every time you load the page, already load the modal. Follow the snippet of code. This way, it works perfectly, but it's getting very slow, so I want to know if you have a%

<?php


if($PERMOT != 0)
{
        echo "<td><a data-toggle='modal' data-target='#modal-$i'>".number_format($log[0], 3)."</a>             </td>";//Gasto
        echo "<td class=".$classTd."><a data-toggle='modal' data-arget='#modal-$i'>".number_format($log[5], 3)."</a></td>";//Diff
                        }
                        else
                            echo "<td><div>-</div><div>-</div><div>-</div></td>";

                    echo "</tr>";
                echo "</tbody>";
                echo "
                    <div class='modal fade' id='modal-$i'>
                        <div class='modal-dialog modal-lg'>
                            <div class='modal-content'>
                                 <div class='modal-header'>
                                    <h4 class='modal-title'>Documento ".$CODFIL."-".$SERDOC." - ".$NUMDOC." </h4>
                                  </div>
                                  <div class='modal-body'>
                                     ".$log[6]."
                                  </div>
                                  <div class='modal-footer'>
                                      <button type='button' class='btn btn-danger' data-dismiss='modal'>Fechar</button>
                                   </div>                   
                            </div>
                        </div>
                    </div>
                ";

                //echo "<button class='info plus  ' id='".$i."' onclick='moreInf($i, $CODFIL, $SERDOC, $NUMDOC)'></button>";
                $i++;

?>
    
asked by anonymous 28.05.2018 / 16:36

1 answer

0

You can try loading the modal directly with the page with an isOpen property set to false when the page loads. You then apply a button with an event / function to modify the isOpen property to open and close Modal.

In this way Modal will already be loaded at the beginning and it will be faster to make the transition between Modal being shown and hidden.

    
28.05.2018 / 16:43