Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

306
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda