Hi,
i have a huge dashboard for my KNX based home automation. Therefor I show svg elements in a template node, depending on a input node (e.g. light is on or off).
This looks like this.
<svg xmlns="http://www.w3.org/2000/svg" height="32" viewBox="0 -960 960 960" width="32">
<path d="{{msg.payload}}" />
</svg>
No I want the svg to be clickable and to send the msg to the output node of the template node. For that I connected the output to a debug node and changed to code to that.
<div id="mySvgButtonId" style="cursor: pointer; display: inline-block;">
<svg xmlns="http://www.w3.org/2000/svg" height="32" viewBox="0 -960 960 960" width="32">
<path d="{{msg.payload}}" />
</svg>
</div>
<script>
(function(scope) {
console.warn('Function reached');
document.getElementById('mySvgButtonId').onclick = function() {
// Send the message to the output
scope.send(scope.msg);
console.warn('svg clicked');
}
})(this);
</script>
Now the svg appears to be clickable (the mouse pointer changes once I hover over the svg) but once I click the svg, no message is send to the output/debug node at all.
Does anybody know what is wrong with the code and has an idea how to fix this?