summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-08-06 16:16:31 +0200
committerJo-Philipp Wich <jo@mein.io>2020-08-06 17:56:34 +0200
commit18eddc962418a045524a740061625834a77153d8 (patch)
tree70264db4f37f252a5d3943e9d12d4ec59aee2d42
parentc44528d40d44c1a0887c4f6bf796560773a8017f (diff)
luci-base: ui.js: implement AbstractElement.isChanged()
The new `isChanged()` utility functions allows to query the dirty state of an ui input widget. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/ui.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js
index 7823182f04..77074d5075 100644
--- a/modules/luci-base/htdocs/luci-static/resources/ui.js
+++ b/modules/luci-base/htdocs/luci-static/resources/ui.js
@@ -128,6 +128,21 @@ var UIElement = baseclass.extend(/** @lends LuCI.ui.AbstractElement.prototype */
},
/**
+ * Check whether the input value was altered by the user.
+ *
+ * @instance
+ * @memberof LuCI.ui.AbstractElement
+ * @returns {boolean}
+ * Returns `true` if the input value has been altered by the user or
+ * `false` if it is unchaged. Note that if the user modifies the initial
+ * value and changes it back to the original state, it is still reported
+ * as changed.
+ */
+ isChanged: function() {
+ return (this.node ? this.node.getAttribute('data-changed') : null) == 'true';
+ },
+
+ /**
* Check whether the current input value is valid.
*
* @instance