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

310
Vistas
Import module for webpack to map <html onclick=""> dependency for JS generated elements

I'm generating and appending elements in JS with template literals. These elements need onclick listeners. Instead of selecting and setting in JS, I thought of putting the onclick in the template instead:

// report.js
export default function report() { console.log('Running') }
// template.js
export default elementHTML = `<div onclick="report()"></div>`
// draw.js
import elementHTML from './template.js'

export default function draw(){
  const container = document.getElementbyId('container')

  for (let i = 0; i < 20; i++) {
     const domElement = document.createElement('div')
     container.appendChild(domElement)
     domElement.outerHTML = elementHTML
  }
}
// index.js
import draw from './draw.js'

draw()

In which file should I import report so that webpack knows to import it as a module dependency for the html onclick to run?

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