luci-base: form.js: support passing a callback to Map.save()
authorJo-Philipp Wich <jo@mein.io>
Mon, 12 Aug 2019 17:45:18 +0000 (19:45 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 14 Aug 2019 20:58:15 +0000 (22:58 +0200)
The given callback function will be executed after the map is parsed,
but before the uci is saved. This is useful to add further uci changes
before the map is re-rendered.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js

index 9c5cb9365044d890f26d5923f4ba318537cc54ec..44a2df22f17d13c938748b0a84e01bc93b65ddab 100644 (file)
@@ -132,10 +132,11 @@ var CBIMap = CBINode.extend({
                return Promise.all(tasks);
        },
 
-       save: function() {
+       save: function(cb) {
                this.checkDepends();
 
                return this.parse()
+                       .then(cb)
                        .then(uci.save.bind(uci))
                        .then(this.load.bind(this))
                        .then(this.renderContents.bind(this))