diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-09-03 19:21:49 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-09-10 15:28:16 +0200 |
commit | 642b8277df5c996a160d23a361593b5bc4f8eb10 (patch) | |
tree | 6c7f311e86ec791e1a2481701a991a6d489bb3d4 /modules/luci-base | |
parent | eac8316e0dffbcee6ca2d20a9b4e2c8383d1d137 (diff) |
luci-base: form.js: use createHandlerFn() for click actions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/form.js | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 34fc097958..be9b53a88c 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -985,7 +985,7 @@ var CBITableSection = CBITypedSection.extend({ 'value': more_label, 'title': more_label, 'class': 'cbi-button cbi-button-edit', - 'click': L.bind(this.renderMoreOptionsModal, this, section_id) + 'click': L.ui.createHandlerFn(this, 'renderMoreOptionsModal', section_id) }) ); } @@ -994,16 +994,14 @@ var CBITableSection = CBITypedSection.extend({ var btn_title = this.titleFn('removebtntitle', section_id); L.dom.append(tdEl.lastElementChild, - E('input', { - 'type': 'submit', - 'value': btn_title || _('Delete'), + E('button', { 'title': btn_title || _('Delete'), 'class': 'cbi-button cbi-button-remove', - 'click': L.bind(function(sid, ev) { + 'click': L.ui.createHandlerFn(this, function(sid, ev) { uci.remove(config_name, sid); - this.map.save(null, true); - }, this, section_id) - }) + return this.map.save(null, true); + }, section_id) + }, [ btn_title || _('Delete') ]) ); } @@ -1153,7 +1151,7 @@ var CBITableSection = CBITypedSection.extend({ } } - Promise.resolve(this.addModalOptions(s, section_id, ev)).then(L.bind(m.render, m)).then(L.bind(function(nodes) { + return Promise.resolve(this.addModalOptions(s, section_id, ev)).then(L.bind(m.render, m)).then(L.bind(function(nodes) { L.ui.showModal(title, [ nodes, E('div', { 'class': 'right' }, [ @@ -1645,15 +1643,13 @@ var CBIButtonValue = CBIValue.extend({ if (value !== false) L.dom.content(outputEl, [ - E('input', { + E('button', { 'class': 'cbi-button cbi-button-%s'.format(this.inputstyle || 'button'), - 'type': 'button', - 'value': btn_title, - 'click': L.bind(this.onclick || function(ev) { + 'click': L.ui.createHandlerFn(this, this.onclick || function(ev) { ev.target.previousElementSibling.value = ev.target.value; - this.map.save(); - }, this) - }) + return this.map.save(); + }) + }, [ btn_title ]) ]); else L.dom.content(outputEl, ' - '); |