luci-mod-system: password.js: make event handler attachment more robust

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 34c06b4704)
This commit is contained in:
Jo-Philipp Wich 2020-04-28 23:33:24 +02:00
parent 9964141082
commit 0c556476f0

View 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();
});