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

169
Vistas
How can I target a button within a temperate literal, for use in a separate click function?

Currently, Im using temperate literals to generate buttons to go along with locally stored data per result. This data is generated via a click which handles calling the storage to get back the information, displaying it a container. However, when I want to target the button, it's unresponsive.

My code

$(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();
    })

Is there a better way to do this? or am I going about it the wrong way? This data is triggered with a previous button click, and when adding an onClick function to the button itself, It's just called every time I generate the list and not when I clicked the button itself which is expected but not what I need.

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