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

238
Vistas
How to execute a function before to call another function

I have a button with an onClick calling a function that unfortunately I can't change. This function performs a login to the application:

<Button onClick={() => signIn()}>

but I need to execute some other code, to check if the user has checked a few checkboxes. Is there a way to call another function before the current one, and prevent the function call if the first one return false?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can get the old onclick value, then replace it with your function that calls the original when it's done checking.

let oldFunc = button.onclick;
button.onclick = function(event) {
    // code to check if the checkboxes are checked
    if (boxes_checked) {
        if (typeof oldFunc == 'string') {
            eval(oldFunc);
        } else {
            return oldFunc(event);
        }
    }
}
about 4 years ago · Santiago Trujillo Denunciar
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