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

174
Vistas
How can I pass custom object to a CustomEvent() using Javascript

I am trying to use vanilla javascript to dispatch a custom event. Along with the event, I would like to pass a custom object.

Here is what I have done

document.addEventListener('abcAppended', function (e) {
     console.log(e.el); // write the custom object to the console
});

var wrapper = document.getElementById('abc');
if (wrapper) {
    // do something with wrapper
   
    document.dispatchEvent(new CustomEvent('abcAppended', {
        el: wrapper // I tried to add custom object here
    }));
}

But the above write undefined to the console. How can I correctly pass an object and access it using a listener.

about 4 years ago · Juan Pablo Isaza
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