luci-base: ui.js: dispatch "cbi-tab-active" event when a tab is selected

This is useful to lazy-load tab contents.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2020-02-12 08:14:22 +01:00
parent e7d22dce50
commit bf774e4c2a

View file

@ -2244,6 +2244,10 @@ return L.Class.extend({
this.setActiveTabId(panes[selected], selected);
}
panes[selected].dispatchEvent(new CustomEvent('cbi-tab-active', {
detail: { tab: panes[selected].getAttribute('data-tab') }
}));
this.updateTabs(group);
},
@ -2354,6 +2358,7 @@ return L.Class.extend({
if (L.dom.matches(pane, '[data-tab]')) {
if (pane.getAttribute('data-tab') === name) {
pane.setAttribute('data-tab-active', 'true');
pane.dispatchEvent(new CustomEvent('cbi-tab-active', { detail: { tab: name } }));
L.ui.tabs.setActiveTabId(pane, index);
}
else {