luci-base: cbi.js: also initialize comboxes embedded in dynlists
authorJo-Philipp Wich <jo@mein.io>
Fri, 13 Sep 2019 11:57:24 +0000 (13:57 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 13 Sep 2019 11:58:28 +0000 (13:58 +0200)
Fixes: #3062
Fixes: 010102c2c ("luci-base: cbi.js: find dropdown and browser instances early")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index 4055ea1a5652b454fc7a2a5b01d0e8071439cd4f..400d25e09c0147be3f6c3bb15166ad72f8b4ff7b 100644 (file)
@@ -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;