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();
}