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

213
Views
¿Cómo pasar la identificación de un objeto a una función js fuera de un for? DJANGO

Tengo un botón de eliminación que elimina un objeto de la base de datos. Este botón tiene una función js windows.confirm para su eliminación. Necesito pasar servico.id a la función para poder hacer referencia al objeto en la vista. ¿Cómo hago esto?

 <a href="#" class="btn btn-danger btn-sm" onclick="return myFunction()">Delete</a>

Guion

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

0

html

 <a href="#" data-id="{{servico.id}}" id="de" class="btn btn-danger btn-sm" onclick="return myFunction()">Delete</a>

js

 <script> function myFunction() { if (window.confirm("Você tem certeza que deseja excluir ?")) { _id = $('#').attr(''data-id) window.location.href="`${window.location.pathname}/${_id}`;"; } } </script>

Usé jquery, necesitas incluirlo.

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!