js: Fix error on app startup

jQuery seems to re-cycle event object references oO
This commit is contained in:
Johannes Meyer 2024-08-07 10:09:12 +02:00
parent 97f8767970
commit 9ef4c71cec
1 changed files with 5 additions and 3 deletions

View File

@ -14,11 +14,13 @@
Autofocus.prototype = new Icinga.EventListener();
Autofocus.prototype.onRendered = function(e) {
setTimeout(function() {
if (document.activeElement === e.target
const _this = e.data.self;
const target = e.target;
setTimeout(() => {
if (document.activeElement === target
|| document.activeElement === document.body
) {
e.data.self.icinga.ui.focusElement($(e.target).find('.autofocus'));
_this.icinga.ui.focusElement($(target).find('.autofocus'));
}
}, 0);
};