luci-base: ui.js: support clearChoices()/addChoices() for DynLists
authorJo-Philipp Wich <jo@mein.io>
Sun, 19 Jan 2020 14:52:58 +0000 (15:52 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sun, 19 Jan 2020 19:15:52 +0000 (20:15 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit cc123a03ce738dffae9abf5aefad9b75020a0a04)

modules/luci-base/htdocs/luci-static/resources/ui.js

index c9dfea03ccd6dcb142ece673da609e9aed1d7ae7..927bda36f26b2c3f420c8afbbc83ac28bc147b27 100644 (file)
@@ -1555,6 +1555,16 @@ var UIDynamicList = UIElement.extend({
                for (var i = 0; i < values.length; i++)
                        this.addItem(this.node, values[i],
                                this.choices ? this.choices[values[i]] : null);
+       },
+
+       addChoices: function(values, labels) {
+               var dl = this.node.lastElementChild.firstElementChild;
+               L.dom.callClassMethod(dl, 'addChoices', values, labels);
+       },
+
+       clearChoices: function() {
+               var dl = this.node.lastElementChild.firstElementChild;
+               L.dom.callClassMethod(dl, 'clearChoices');
        }
 });