luci-base: cbi.js: add cbi_submit() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
9bdd097f53
commit
7b43e81c9b
1 changed files with 22 additions and 0 deletions
|
@ -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()
|
String.prototype.format = function()
|
||||||
{
|
{
|
||||||
if (!RegExp)
|
if (!RegExp)
|
||||||
|
|
Loading…
Reference in a new issue