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

View File

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