I please need your eyes, because I don't see my mistake...
Tried to build a template node that shows the Title "ID" and copies on click msg.payload to the clipboard of the browser where it's being clicked. Here is the code inside the template node. And where is my error?
<div/><button onclick="copyText('{{msg.id}}')">ID:</button></div>
<script>
function copyText(inhalt){
/* Copy text into clipboard */
navigator.clipboard.writeText(inhalt);
}
</script>
I always get "{{msg.id}}" to the clipboard, but not the value of it...
Are you using the template or ui-template node?
are you using dashboard 1 or 2?
why do you have a backslash in the first div of the first line? i.e. <div/><button...
Thanks E1cid,
but this also doesn't work. I think that the problem is, that the (msg.id) or {{msg.id}} is between two "s. But I have no idea how it could be right.
You will need to use md-button and you'll need to store the id somewhere that is in scope.
You could bind the id to a hidden input then retrieve it in your function. Or catch incoming messages using the sample code in the built in help & store the id in a variable.
And yes, I reloaded the site several times...
But now I've learned how to get the information to the "Click me to copy my value to clipboard" Buttons! Great!