From: Jo-Philipp Wich Date: Tue, 3 Sep 2019 17:30:29 +0000 (+0200) Subject: luci-base: cbi.js: handle ui elements which return a promise in render() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1fcf34510a6c7994df3ca95e2e754db19870ce4b;p=oweals%2Fluci.git luci-base: cbi.js: handle ui elements which return a promise in render() 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 a3528fcac..5aa687b67 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -321,8 +321,10 @@ function cbi_init() { widget = new (Function.prototype.bind.apply(L.ui[args[0]], args)), markup = widget.render(); - markup.addEventListener('widget-change', cbi_d_update); - node.parentNode.replaceChild(markup, node); + Promise.resolve(markup).then(function(markup) { + markup.addEventListener('widget-change', cbi_d_update); + node.parentNode.replaceChild(markup, node); + }); }); cbi_d_update();