gluon-web-model: add custom events for form elements

This commit is contained in:
Matthias Schiffer 2018-08-19 12:29:30 +02:00
parent a3a1d217f2
commit ba1df47dba
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
2 changed files with 6 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -183,6 +183,8 @@
} }
function update() { function update() {
window.dispatchEvent(new Event('gluon-update'));
var state = false; var state = false;
for (var id in dep_entries) { for (var id in dep_entries) {
var entry = dep_entries[id]; var entry = dep_entries[id];
@ -191,6 +193,7 @@
if (node && node.parentNode && !check(entry.deps)) { if (node && node.parentNode && !check(entry.deps)) {
node.parentNode.removeChild(node); node.parentNode.removeChild(node);
node.dispatchEvent(new Event('gluon-hide'));
state = true; state = true;
} else if (parent && (!node || !node.parentNode) && check(entry.deps)) { } else if (parent && (!node || !node.parentNode) && check(entry.deps)) {
var next = undefined; var next = undefined;
@ -207,6 +210,7 @@
parent.insertBefore(entry.node, next); parent.insertBefore(entry.node, next);
} }
entry.node.dispatchEvent(new Event('gluon-show'));
state = true; state = true;
} }
@ -471,6 +475,7 @@
bind(field, "blur", validator); bind(field, "blur", validator);
bind(field, "keyup", validator); bind(field, "keyup", validator);
bind(field, "gluon-revalidate", validator);
if (field.nodeName.toLowerCase() == 'select') { if (field.nodeName.toLowerCase() == 'select') {
bind(field, "change", validator); bind(field, "change", validator);