Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!