From: Jo-Philipp Wich Date: Tue, 10 Sep 2019 15:07:36 +0000 (+0200) Subject: luci-base: cbi.js: find dropdown and browser instances early X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=010102c2c;p=oweals%2Fluci.git luci-base: cbi.js: find dropdown and browser instances early Gather dropdown and file browser widget nodes early, before initializing dynamic list widgets as dynlists invoke a dependency update which in turn might remove widget nodes from dom before they have been initialized. Ref: https://github.com/openwrt/luci/issues/2997#issuecomment-524251601 Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index fa61cf644..0de7bcb9c 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -736,7 +736,9 @@ function cbi_d_update() { } function cbi_init() { - var nodes; + var dropdowns = document.querySelectorAll('.cbi-dropdown'), + browsers = document.querySelectorAll('[data-browser]'), + nodes; nodes = document.querySelectorAll('[data-strings]'); @@ -808,8 +810,8 @@ function cbi_init() { node.getAttribute('data-type')); } - document.querySelectorAll('.cbi-dropdown').forEach(cbi_dropdown_init); - document.querySelectorAll('[data-browser]').forEach(cbi_browser_init); + dropdowns.forEach(cbi_dropdown_init); + browsers.querySelectorAll('[data-browser]').forEach(cbi_browser_init); document.querySelectorAll('.cbi-tooltip:not(:empty)').forEach(function(s) { s.parentNode.classList.add('cbi-tooltip-container');