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

170
Views
¿Cómo puedo apuntar a un botón dentro de un literal templado, para usarlo en una función de clic separada?

Actualmente, estoy usando literales moderados para generar botones para acompañar los datos almacenados localmente por resultado. Estos datos se generan a través de un clic que maneja llamar al almacenamiento para recuperar la información, mostrándola en un contenedor. Sin embargo, cuando quiero apuntar al botón, no responde.

Mi código

 $(document).ready(() => { const genMonthlyQueueBtn = $("#genMonthlyQueue"); const genTransientQueueBtn = $("#genTransientQueue"); const monthlyPlateQueue = () => { const $insertMonthly = $('#insertMonthlyPlates'); $insertMonthly.empty(); let monthlyPlates = JSON.parse(localStorage.getItem('Monthly Plates')); for (i = 0; i < monthlyPlates.length; i++) { console.log(monthlyPlates); $insertMonthly.append(` <div class="container" id="generatedMonthlyPlates"> <input type="text" width="100px" name="monthlyLicensePlate" id="monthlyLicensePlate" class="licensePlate" placeholder="AB12345" value=${monthlyPlates[i]}/> <div class="text-center"> <button class="btn btn-warning" type="submit" id="editMonthlyPlate" name="action">Edit <i class="material-icons right">edit</i> </button> <button class="btn btn-danger" type="submit" id="deletePlate" name="action">Delete <i class="material-icons right">delete</i> </button> </div> </div> `) } } // get the array from local storage through queue function genMonthlyQueueBtn.click(() => { monthlyPlateQueue(); }) // call generated button and test functionality to edit and push back to storage const editMonthlyPlateBtn = $('#editMonthlyPlate'); const editMonthlyPlate = () => { console.log('I was clicked'); } editMonthlyPlateBtn.click(() => { editMonthlyPlate(); })

¿Hay una mejor manera de hacer esto? ¿O lo estoy haciendo de la manera incorrecta? Estos datos se activan con un clic de botón anterior, y cuando se agrega una función onClick al botón en sí, solo se llama cada vez que genero la lista y no cuando hago clic en el botón en sí, lo que se espera pero no lo que necesito.

about 4 years ago · Santiago Trujillo
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!