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

225
Views
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 answers
Answer question

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 Report
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!