diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-09-14 17:20:41 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-09-14 17:20:41 +0200 |
commit | 208bf47a33d5b6f1febd51785958ffefe25afc64 (patch) | |
tree | 60b79c2c6d1b42c2c6e2be6858303609c7fc6d61 | |
parent | 7c9d1a259ca739bec577a89481b92c1ae2cc3c22 (diff) |
luci-base: cbi.js: update dependencies after widgets have been rendered
Fixes: #3066
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/cbi.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 9144fbaf62..4c3128bfd1 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -314,18 +314,20 @@ function cbi_init() { i.addEventListener('mouseout', handler); }); + var tasks = []; + document.querySelectorAll('[data-ui-widget]').forEach(function(node) { var args = JSON.parse(node.getAttribute('data-ui-widget') || '[]'), widget = new (Function.prototype.bind.apply(L.ui[args[0]], args)), markup = widget.render(); - Promise.resolve(markup).then(function(markup) { + tasks.push(Promise.resolve(markup).then(function(markup) { markup.addEventListener('widget-change', cbi_d_update); node.parentNode.replaceChild(markup, node); - }); + })); }); - cbi_d_update(); + Promise.all(tasks).then(cbi_d_update); } function cbi_validate_form(form, errmsg) |