diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-08-08 08:34:27 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-08-14 22:58:15 +0200 |
commit | 46861a527e0ba67a99b21eb8af4e5790922f5da1 (patch) | |
tree | 986f12312a703196068839b61acff4ff2377b1f8 /modules/luci-base/htdocs/luci-static/resources | |
parent | 3789148fc99f2c68525767689d65e6ad67292e0f (diff) |
luci-base: form.js: fix rendering of button widgets
Also introduce an `onclick` property to allow registering custom button
action handler.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/form.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 1c1c9c8c9..a417616d2 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -1585,28 +1585,29 @@ var CBIButtonValue = CBIValue.extend({ __name__: 'CBI.ButtonValue', renderWidget: function(section_id, option_index, cfgvalue) { - var value = (cfgvalue != null) ? cfgvalue : this.default; + var value = (cfgvalue != null) ? cfgvalue : this.default, + hiddenEl = new ui.Hiddenfield(value, { id: this.cbid(section_id) }), + outputEl = E('div'); if (value !== false) - return E([ - E('input', { - 'type': 'hidden', - 'id': this.cbid(section_id) - }), + L.dom.content(outputEl, [ E('input', { 'class': 'cbi-button cbi-button-%s'.format(this.inputstyle || 'button'), - 'type': 'submit', - //'id': this.cbid(section_id), - //'name': this.cbid(section_id), + 'type': 'button', 'value': this.inputtitle || this.title, - 'click': L.bind(function(ev) { + 'click': L.bind(this.onclick || function(ev) { ev.target.previousElementSibling.value = ev.target.value; this.map.save(); }, this) }) ]); else - return document.createTextNode(' - '); + L.dom.content(outputEl, ' - '); + + return E([ + outputEl, + hiddenEl.render() + ]); } }); |