luci-base: form.js: use createHandlerFn() for click actions

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2019-09-03 19:21:49 +02:00
parent eac8316e0d
commit 642b8277df

View file

@ -985,7 +985,7 @@ var CBITableSection = CBITypedSection.extend({
'value': more_label, 'value': more_label,
'title': more_label, 'title': more_label,
'class': 'cbi-button cbi-button-edit', '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); var btn_title = this.titleFn('removebtntitle', section_id);
L.dom.append(tdEl.lastElementChild, L.dom.append(tdEl.lastElementChild,
E('input', { E('button', {
'type': 'submit',
'value': btn_title || _('Delete'),
'title': btn_title || _('Delete'), 'title': btn_title || _('Delete'),
'class': 'cbi-button cbi-button-remove', '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); uci.remove(config_name, sid);
this.map.save(null, true); return this.map.save(null, true);
}, this, section_id) }, 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, [ L.ui.showModal(title, [
nodes, nodes,
E('div', { 'class': 'right' }, [ E('div', { 'class': 'right' }, [
@ -1645,15 +1643,13 @@ var CBIButtonValue = CBIValue.extend({
if (value !== false) if (value !== false)
L.dom.content(outputEl, [ L.dom.content(outputEl, [
E('input', { E('button', {
'class': 'cbi-button cbi-button-%s'.format(this.inputstyle || 'button'), 'class': 'cbi-button cbi-button-%s'.format(this.inputstyle || 'button'),
'type': 'button', 'click': L.ui.createHandlerFn(this, this.onclick || function(ev) {
'value': btn_title,
'click': L.bind(this.onclick || function(ev) {
ev.target.previousElementSibling.value = ev.target.value; ev.target.previousElementSibling.value = ev.target.value;
this.map.save(); return this.map.save();
}, this) })
}) }, [ btn_title ])
]); ]);
else else
L.dom.content(outputEl, ' - '); L.dom.content(outputEl, ' - ');