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

216
Vistas
How to delete an object with a windows.confirm?

I have a template that lists all the activities of a client. In this template, I have a button to delete any activity I choose. This button has a confirmation to delete through a windows.confirm. But it's not working the way you expect. Sometimes the button works, sometimes it doesn't.

{% for servico in object_list %}                   
     {{ servico.refferring_funcionario }}
     {{ servico.get_lista_servico_display }}
     {{ servico.data_servico }}
     R$ {{ servico.valor_servico }}
     <a href="{% url 'servico:editar-servico' servico.id %}" class="btn btn-secondary btn-sm">Edit</a>
     <a href="" class="btn btn-danger btn-sm" onclick="return myFunction()">Delete</a>
{% endfor %}

Js

<script>
   function myFunction() {
        if (window.confirm("Você tem certeza que deseja excluir ?")) {                                      
            window.location.href="{% url 'servico:excluir-servico' servico.id %}";
        }
   }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't think this is the problem, but to start solving the problem I would set the value of href to #

<a href="#" class="btn btn-danger btn-sm" onclick="return myFunction()">Delete</a>
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