luci-mod-system: password.js: make event handler attachment more robust
authorJo-Philipp Wich <jo@mein.io>
Tue, 28 Apr 2020 21:33:24 +0000 (23:33 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 7 May 2020 17:40:49 +0000 (19:40 +0200)
Do not expect a specific markup structure but use querySelector() to locate
the input element.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 34c06b4704383428c87e0a3c3c96ff7facfa5c46)

modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js

index 2b79633cac1deb9cf574ad5923a401fe8f1a1333..a5f1cd9b90bf7ba76abba29ec55fd9e0c8e03e32 100644 (file)
@@ -55,7 +55,7 @@ return view.extend({
                o.renderWidget = function(/* ... */) {
                        var node = form.Value.prototype.renderWidget.apply(this, arguments);
 
-                       node.childNodes[1].addEventListener('keydown', function(ev) {
+                       node.querySelector('input').addEventListener('keydown', function(ev) {
                                if (ev.keyCode == 13 && !ev.currentTarget.classList.contains('cbi-input-invalid'))
                                        document.querySelector('.cbi-button-save').click();
                        });