Hi,
iI searched and tryed many options to get a payload out of this ui-template-node.
Wether version 1 or Version 2 is sending an outpout to a Debug-node.
have no more idea what´s wrong?
Using v3.1.3 and old Dashboard.
Version 1
<span class="toggle">
<input type="checkbox"id="checkbox1" onchange="toggleState(this)">
<label data-off="OFF" data-on="ON"></label>
</span>
<script>
function toggleState(checkbox) {
var msg = { payload: "" };
if (checkbox.checked)
{
msg.payload = "TRUE";
}
else
{
msg.payload = "FALSE";
}
node.send(msg);
}
</script>
Version 2
<span class="toggle">
<input type="checkbox" onclick="onClickHandler(msg)" id="box3" />
<label data-off="AUS" data-on="AN"></label>
</span>
<script>
function onClickHandler(msg)
{
var offValue = event.target.getAttribute('data-off');
var onValue = event.target.getAttribute('data-on');
var msg = { payload: "" };
if (offValue === 'AUS')
{
msg.payload = "TRUE";
return msg;
}
else if (onValue === 'AN')
{
msg.payload = FALSE;
return msg;
}
}
</script>
Thank you for your Idea:
steelbuddy