Open modal window before clicking the close button

0

How can I make a valuation modal skip when they are going to close the session, but of course only one time, I did a test but it always comes out and of course it does not let me close my session.

Close session button

<li class="nav-item" style="width: 100%;">
  <a class="nav-link confirmation" href="logout.php" onMouseOver="$('#modal-valora').modal('show');"><i class="fas fa-sign-out-alt margsvg "></i> Cerrar Sesión</a>
</li>

The modal:

<div class="modal fade" id="modal-valora" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
   <div class="modal-dialog" role="document">
   <img src="images/logo/logo.svg" alt="DepilDiodo" class="logo-modal">
      <div class="modal-content">
      <div class="modal-header">
      <h5 class="modal-title modal-titulo" id="exampleModalLabel" style="font-size: 20px; font-weight: 600; margin-left:20%;">¿Como valoras tu experiencia?</h5>
     <button type="button" class="boton-cerrar" data-dismiss="modal" aria-label="Close">
       <span aria-hidden="true">&times;</span>
     </button>
     </div>
     <div class="modal-body">
    <form>
     <p class="clasificacion center" style="margin-top: -12px; margin-bottom: 3%;">
     <input id="radio1" type="radio" name="estrellas" value="5">
     <label for="radio1">★</label>
     <input id="radio2" type="radio" name="estrellas" value="4">
     <label for="radio2">★</label>
     <input id="radio3" type="radio" name="estrellas" value="3">
     <label for="radio3">★</label>
     <input id="radio4" type="radio" name="estrellas" value="2">
     <label for="radio4">★</label>
     <input id="radio5" type="radio" name="estrellas" value="1">
     <label for="radio5">★</label>
     </p>
     <textarea name="" id="" cols="30" rows="3" style="width: 100%;font-size: 13px;" placeholder="Recomiendanos ¿Estás contento/a con el servicio?"></textarea>

     <button type="submit" class="btn btn-primary btnen pull-right" style="border-radius: 25px; float: right;">Enviar</button>
     <button type="button" class="btn btn-primary btclos pull-right" data-dismiss="modal" aria-label="Close" style="border-radius: 25px; float: right;">Cerrar</button>
     </form>
         </div>
        <div class="modal-footer">
       <p class="pmoda" style="margin-bottom: 0px;"><i class="fas fa-lock"></i> Todos los datos están protegidos de forma <br>segura (HTTP/SSL)</p>
            </div>
          </div>
       </div>
    </div> 

Any suggestions ???

    
asked by Miguel 10.09.2018 в 11:53
source

1 answer

1

Take the code that controls the onMouseOver event to a function that you declare in some script section or javascript file that you import. In addition, you declare a variable that controls if the modal has already been shown and you put an if to check the value of said variable to see if it is shown or not. So it would be in a script section, for example:

<script> 
    var modalMostrado = false; 
    function showModalValoracion() { 
        if (!modalMostrado) { 
            $('#modal-valora').modal('show'); 
            modalMostrado = true; 
        } 
    } 
</script>

And so the part of the event:

onMouseOver="showModalValoracion();"
    
answered by 10.09.2018 / 13:09
source