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
How to focus on ui element with cached jquery selector

I have an input element that I would like to attach a shortcut. I have cached the jquery selector because element never changes. I have used HotKeys to attach a shortcut; '/' will focus on the input box. The shortcut itself triggers but I cannot focus on the input box. If don't use cached selector, it works. I believe I am messing up with 'this' pointer or something else.

I appreciate if someone can take a look and let know what is wrong with this approach.

Thanks!

function Lister() {
    this.uiQueryBox = $('#query-box');
}

Lister.prototype._setEvents = function () {
    let self = this;

    HotKeys('/', function (event, handler) {
      event.preventDefault();
      self._focusOnQuery();
    });
}

Lister.prototype._focusOnQuery = function() {  
  this.uiQueryBox.focus();
}
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