SVGHMI: fix js exception because of trying to find already detached elements by id.
authorEdouard Tisserant
Fri, 08 Jul 2022 11:58:10 +0200
changeset 3536 4ee33be5b8b6
parent 3535 770fcb344f50
child 3538 d6c9da8d594e
child 3553 406eb8a13648
SVGHMI: fix js exception because of trying to find already detached elements by id.
svghmi/widget_input.ysl2
--- a/svghmi/widget_input.ysl2	Wed Jul 06 10:39:11 2022 +0200
+++ b/svghmi/widget_input.ysl2	Fri Jul 08 11:58:10 2022 +0200
@@ -65,6 +65,8 @@
     const "have_edit","string-length($edit_elt)>0";
     value "$edit_elt";
 
+    const "action_elements", "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]";
+
     if "$have_value"
     |     frequency: 5,
     |     dispatch: function(value) {
@@ -94,6 +96,9 @@
     |     },
     }
 
+    foreach "$action_elements" {
+    |     action_elt_«position()»: id("«@id»"),
+    }
     |     init: function() {
 
     if "$have_edit" {
@@ -104,8 +109,8 @@
     |         this.animate();
     }
 
-    foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
-    |         id("«@id»").onclick = () => this.on_op_click("«func:escape_quotes(@inkscape:label)»");
+    foreach "$action_elements" {
+    |         this.action_elt_«position()».onclick = () => this.on_op_click("«func:escape_quotes(@inkscape:label)»");
     }
 
     if "$have_value" {