From: Jo-Philipp Wich Date: Fri, 13 Sep 2019 11:57:24 +0000 (+0200) Subject: luci-base: cbi.js: also initialize comboxes embedded in dynlists X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a3573524531f761cc6f2a9d46b96bb01f4ef027e;p=oweals%2Fluci.git luci-base: cbi.js: also initialize comboxes embedded in dynlists Fixes: #3062 Fixes: 010102c2c ("luci-base: cbi.js: find dropdown and browser instances early") 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 4055ea1a5..400d25e09 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -802,6 +802,8 @@ function cbi_init() { } cbi_dynlist_init(node, choices[2], choices[3], options); + + node.querySelectorAll('.cbi-dropdown').forEach(cbi_dropdown_init); } nodes = document.querySelectorAll('[data-type]'); @@ -1954,6 +1956,9 @@ function cbi_dropdown_init(sb) { if (!(this instanceof cbi_dropdown_init)) return new cbi_dropdown_init(sb); + if (sb.classList.contains('initialized')) + return; + this.multi = sb.hasAttribute('multiple'); this.optional = sb.hasAttribute('optional'); this.placeholder = sb.getAttribute('placeholder') || '---'; @@ -2049,6 +2054,8 @@ function cbi_dropdown_init(sb) { li.setAttribute('unselectable', ''); li.addEventListener('click', this.handleCreateClick.bind(this)); } + + sb.classList.add('initialized'); } cbi_dropdown_init.prototype = CBIDropdown;