luci-base: delay cbi-tab-active event on tab init

Delay the cbi-tab-active custom event so any eventListner attached to the tab doesn't miss the first event.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
This commit is contained in:
Ansuel Smith 2020-11-24 02:36:50 +01:00
parent 44d02afab1
commit 84ba852993
No known key found for this signature in database
GPG key ID: AC001D09ADBFEAD7

View file

@ -3597,9 +3597,11 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
this.setActiveTabId(panes[selected], selected);
}
panes[selected].dispatchEvent(new CustomEvent('cbi-tab-active', {
detail: { tab: panes[selected].getAttribute('data-tab') }
}));
requestAnimationFrame(L.bind(function(pane) {
pane.dispatchEvent(new CustomEvent('cbi-tab-active', {
detail: { tab: pane.getAttribute('data-tab') }
}));
}, this, panes[selected]));
this.updateTabs(group);
},