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

220
Views
e no está definido, la sintaxis correcta para una función de controlador recursivo

¿Cómo hacer una llamada recursiva correcta? En este código la consola me dice "e is undefined". Es un detector de eventos para un botón ul en una lista desordenada.

Este es mi código:

 $("button#ul").on("click", function(event){ var button = $(this); $(button).toggleClass("active"); if ($(button).hasClass('active')){ //event listener $(document).on("keydown", **checkExit** = function(e) { if (exit(e) == true){ $(button).removeClass('active'); $(this).off("keydown"); } **checkExit();** }); function exit(event){ // alert("prevKeyCode: "+prevKeyCode); var code = event.keyCode || event.which; var doubleEnter = (code == 13 && prevKeyCode == code); if (event.type == "click"){ return true; } else if (event.type == 'keydown'){ if (code == 27 || doubleEnter) { prevKeyCode = null; return true; } else if (code == 13) { prevKeyCode = 13; } else { prevKeyCode = code; } return false; } }

Creo que debería definir fuera de la función checkExit...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe pasar el evento como un parámetro cuando vuelva a llamar a checkExit :

 $(document).on("keydown", checkExit = function(e) { if (exit(e) == true) { $('button').removeClass('active'); $(this).off("keydown"); //spegne il gestore corrente } checkExit(e); });
about 4 years ago · Juan Pablo Isaza 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!