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

311
Views
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
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!