summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources/cbi.js
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-07-18 11:23:50 +0200
committerJo-Philipp Wich <jo@mein.io>2018-07-18 12:05:05 +0200
commit7b43e81c9b88df9623cfa22a79627558787378ea (patch)
tree266d58d5f42f7550792054a29458f3e328f80be0 /modules/luci-base/htdocs/luci-static/resources/cbi.js
parent9bdd097f53160a9d7c7ee536ee61f5282eaa7955 (diff)
luci-base: cbi.js: add cbi_submit() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources/cbi.js')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index ddbff83418..89dfac9e46 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -1306,6 +1306,28 @@ function cbi_tag_last(container)
}
}
+function cbi_submit(elem, name, value, action)
+{
+ var form = elem.form || findParent(elem, 'form');
+
+ if (!form)
+ return false;
+
+ if (action)
+ form.action = action;
+
+ if (name) {
+ var hidden = form.querySelector('input[type="hidden"][name="%s"]'.format(name)) ||
+ E('input', { type: 'hidden', name: name });
+
+ hidden.value = value || '1';
+ form.appendChild(hidden);
+ }
+
+ form.submit();
+ return true;
+}
+
String.prototype.format = function()
{
if (!RegExp)