gluon-web-model: update inputs on form reset

Register to 'reset' event on form element and make call to 'update' function
delayed in 'data-update' handler to allow the form values to update beforehand.

When using a form's 'reset' button, form field visibility was not updated.
This could lead to situations where a checkbox had to be toggled again
twice to display the detail text inputs. (Example taken from private
wifi package)

(cherry picked from commit bf090a8a83)
(cherry picked from commit 02e213a718)
This commit is contained in:
Kasalehlia 2020-04-05 12:38:44 +02:00 committed by Martin Weinelt
parent 70990f6732
commit 45ac73a597
3 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
<form method="post" enctype="multipart/form-data" action="<%|url(request)%>"> <form method="post" enctype="multipart/form-data" action="<%|url(request)%>" data-update="reset">
<input type="hidden" name="token" value="<%=token%>" /> <input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="<%=id%>" value="1" /> <input type="hidden" name="<%=id%>" value="1" />

File diff suppressed because one or more lines are too long

View File

@ -517,7 +517,7 @@
for (var i = 0, node; (node = nodes[i]) !== undefined; i++) { for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
var events = node.getAttribute('data-update').split(' '); var events = node.getAttribute('data-update').split(' ');
for (var j = 0, event; (event = events[j]) !== undefined; j++) { for (var j = 0, event; (event = events[j]) !== undefined; j++) {
bind(node, event, update); bind(node, event, function () {setTimeout(update, 0);});
} }
} }