luci-base: delay cbi-tab-active event on tab init
authorAnsuel Smith <[email protected]>
Tue, 24 Nov 2020 01:36:50 +0000 (02:36 +0100)
committerAnsuel Smith <[email protected]>
Tue, 24 Nov 2020 01:36:50 +0000 (02:36 +0100)
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 <[email protected]>
modules/luci-base/htdocs/luci-static/resources/ui.js

index 77074d50757f8bbb9eb959bf8c8cebcfd9944f8e..e35a26a8baed201b4b9f14161f4b912ec50cf8ce 100644 (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);
                },