luci-base: cbi.js: update dependencies after widgets have been rendered
Fixes: #3066 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
7c9d1a259c
commit
208bf47a33
1 changed files with 5 additions and 3 deletions
|
@ -314,18 +314,20 @@ function cbi_init() {
|
||||||
i.addEventListener('mouseout', handler);
|
i.addEventListener('mouseout', handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var tasks = [];
|
||||||
|
|
||||||
document.querySelectorAll('[data-ui-widget]').forEach(function(node) {
|
document.querySelectorAll('[data-ui-widget]').forEach(function(node) {
|
||||||
var args = JSON.parse(node.getAttribute('data-ui-widget') || '[]'),
|
var args = JSON.parse(node.getAttribute('data-ui-widget') || '[]'),
|
||||||
widget = new (Function.prototype.bind.apply(L.ui[args[0]], args)),
|
widget = new (Function.prototype.bind.apply(L.ui[args[0]], args)),
|
||||||
markup = widget.render();
|
markup = widget.render();
|
||||||
|
|
||||||
Promise.resolve(markup).then(function(markup) {
|
tasks.push(Promise.resolve(markup).then(function(markup) {
|
||||||
markup.addEventListener('widget-change', cbi_d_update);
|
markup.addEventListener('widget-change', cbi_d_update);
|
||||||
node.parentNode.replaceChild(markup, node);
|
node.parentNode.replaceChild(markup, node);
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
cbi_d_update();
|
Promise.all(tasks).then(cbi_d_update);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cbi_validate_form(form, errmsg)
|
function cbi_validate_form(form, errmsg)
|
||||||
|
|
Loading…
Reference in a new issue