luci-base: ui.js: fix UICheckbox widget operation when tooltips are set
When a tooltip is rendered for a checkbox widget, an additional node is placed after the checkbox label element, breaking DOM selectors in bind(), isChecked(), setValue(). Apparently the functionality was never actually tested. Fixes: #4938 Fixes:e951236e3
("luci-base: add tooltip handling") Signed-off-by: Jo-Philipp Wich <jo@mein.io> (cherry picked from commit95b5c6cd64
)
This commit is contained in:
parent
b60b838027
commit
adcc2ef446
1 changed files with 5 additions and 4 deletions
|
@ -633,8 +633,9 @@ var UICheckbox = UIElement.extend(/** @lends LuCI.ui.Checkbox.prototype */ {
|
||||||
bind: function(frameEl) {
|
bind: function(frameEl) {
|
||||||
this.node = frameEl;
|
this.node = frameEl;
|
||||||
|
|
||||||
this.setUpdateEvents(frameEl.lastElementChild.previousElementSibling, 'click', 'blur');
|
var input = frameEl.querySelector('input[type="checkbox"]');
|
||||||
this.setChangeEvents(frameEl.lastElementChild.previousElementSibling, 'change');
|
this.setUpdateEvents(input, 'click', 'blur');
|
||||||
|
this.setChangeEvents(input, 'change');
|
||||||
|
|
||||||
dom.bindClassInstance(frameEl, this);
|
dom.bindClassInstance(frameEl, this);
|
||||||
|
|
||||||
|
@ -650,7 +651,7 @@ var UICheckbox = UIElement.extend(/** @lends LuCI.ui.Checkbox.prototype */ {
|
||||||
* Returns `true` when the checkbox is currently checked, otherwise `false`.
|
* Returns `true` when the checkbox is currently checked, otherwise `false`.
|
||||||
*/
|
*/
|
||||||
isChecked: function() {
|
isChecked: function() {
|
||||||
return this.node.lastElementChild.previousElementSibling.checked;
|
return this.node.querySelector('input[type="checkbox"]').checked;
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
|
@ -662,7 +663,7 @@ var UICheckbox = UIElement.extend(/** @lends LuCI.ui.Checkbox.prototype */ {
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
setValue: function(value) {
|
setValue: function(value) {
|
||||||
this.node.lastElementChild.previousElementSibling.checked = (value == this.options.value_enabled);
|
this.node.querySelector('input[type="checkbox"]').checked = (value == this.options.value_enabled);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue