luci-base: cbi.js: handle ui elements which return a promise in render()
authorJo-Philipp Wich <jo@mein.io>
Tue, 3 Sep 2019 17:30:29 +0000 (19:30 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 10 Sep 2019 13:28:16 +0000 (15:28 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index a3528fcaceab3796be12b9cdb6f8f01ba79fa942..5aa687b670831a0351a5e7fe4edbb397029cf6e0 100644 (file)
@@ -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();