Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
Flask add modal to ask before deleting. How to get working?

In my Flask APP i have a page with a link to delete: Is inside a table each row have this id, here I am sending the ID (that normaly I use to delete):

   <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" id="submits" onclick="send_to_modal('{{post.id}}')">
  Borrar
  </button>

Here is my javascript:

function send_to_modal(id){
    document.getElementById("exampleModalLabel").innerHTML = id;

};

The modal:

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">        </button>
      </div>
      <div class="modal-body">

        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-success" onclick="modal_a_funccion()">SI</button>
        <button type="button" class="btn btn-danger" data-bs-dismiss="modal">NO</button>
      </div>
    </div>
  </div>
</div>

I don´t know how to send the ID to another function that is charged to delete the specified data:

This is my function that works correcty and delete the data giving the ID:

function modal_a_funccion(id){
        console.log("Solicitando un report para: "+id);
        //fetch('/report/' + olt_hostname).then(function(response) {
        fetch('/task/report_celery/' + id).then(function(response) {
                response.json().then(function(data) {
                    for (var x of data.ip) {
                        console.log("REPORT_fetch recibe (IP): " +x.ip_oob)
                        console.log("REPORT_fetch recibe (ESTADO): " +x.estado)

                    };
                });
            });
    };

I would like to know how to to it.

What I intend to do is add a modal to ask the user for confirmation whether or not to delete. I can't find a way to pass the Id to the function that is in charge of doing the deletion. I would like to know how to do it. Thank you so much.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A possible solution (in a different way)

  1. When user clicks on delete for a row, add a class e.g. to_delete. Then display the modal popup asking if user wants to go ahead with the delete or not.

  2. If user says no, close the modal and remove the class again

  3. If user says yes, call the delete function

For 3, you do something like

    // Find the element that user has marked for delete
    const element = document.querySelect(".to_delete")
    const id = element.id;

For 2, you do something like

   // Find the element that user has marked for delete and remove the delete mark
   document.querySelect(".to_delete").classList.remove("to_delete")
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda