Hi all,
I have a ui template for a custom widget, within a html table.
This ui template needs to send out a message
A message arriving in the ui template triggers an output message.
To understand the code, I have removed all unnecessary code in the ui template to understand better.
The code is now quite simple, but can't make it work.
I can see in the console the "here!" message , but there is no message going out the ui template to the debug node
<script>
(function(scope) {
scope.$watch('msg', function(msg) {
if (msg) {
console.log("here!");
scope.send({payload: "test_send"});
}
});
})(scope);
</script>
[
{
"id": "a3ad21bb.8e08a8",
"type": "ui_template",
"z": "7474abc19b8e3f3e",
"group": "ada4e0c8.ca2d58",
"name": "",
"order": 0,
"width": 0,
"height": 0,
"format": "<h3>Testing template</h3>\n<p>{{msg.payload}}</p>\n<script>\n (function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg) {\n console.log(\"Fire!\");\n scope.send({msg.payload: \"youpi\"});\n //$(\"#my_\"+scope.$id).html(msg.payload);\n }\n });\n })(scope);\n</script>",
"storeOutMessages": true,
"fwdInMessages": false,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 420,
"y": 160,
"wires": [
[
"8105303d105fe438"
]
]
},
{
"id": "9d387518.22ba48",
"type": "inject",
"z": "7474abc19b8e3f3e",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "",
"payload": "One",
"payloadType": "str",
"x": 203,
"y": 160,
"wires": [
[
"a3ad21bb.8e08a8",
"0a8b2dfa54fb14c7"
]
]
},
{
"id": "8105303d105fe438",
"type": "debug",
"z": "7474abc19b8e3f3e",
"name": "debug 73",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 160,
"wires": []
},
{
"id": "ada4e0c8.ca2d58",
"type": "ui_group",
"z": "7474abc19b8e3f3e",
"name": "Default",
"tab": "e4c8df5a.bc9048",
"order": 1,
"disp": true,
"width": "6"
},
{
"id": "e4c8df5a.bc9048",
"type": "ui_tab",
"z": "7474abc19b8e3f3e",
"name": "tab2",
"icon": "dashboard",
"order": 1
}
]