Hello. Recently I tried to use ui template in addition to my usual dashboard feature, then I came across
this material
(many thanks to @E1cid !!!)
I tried to send a payload from the html back to node-red but it seems I don't know how to updates the value itself. The sent payload still send me "text1" which is the initial payload I sent to the html, even tho I have changed it to other string. Could someone tell me how to update those value? Many thanks!
[
{
"id": "9c0950b1.c61b1",
"type": "inject",
"z": "54a8ecc484312545",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "chart1",
"payload": "[\"text1\"]",
"payloadType": "json",
"x": 180,
"y": 620,
"wires": [
[
"4bc18ffc.98da38"
]
]
},
{
"id": "4bc18ffc.98da38",
"type": "function",
"z": "54a8ecc484312545",
"name": "",
"func": "var sendButton = \" <script> var value = document.getElementById(\\\"w0\\\").value; this.scope.action = function() { return value; } </script> <md-button ng-click= \\\"send({ payload: action() })\\\"> Click here to send the data </md-button>\"\n\n\n\nvar html = \"\";\nfor (var i in msg.payload){\n html = html + '<label for=\"w' + i + '\">A title ' + i + '</label><textarea id=\"w' + i + '\" name=\"w' + i + '\" rows=\"4\" cols=\"50\">' + msg.payload[i] + '</textarea>';\n}\n\n\nmsg.template = html + sendButton ;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 450,
"y": 680,
"wires": [
[
"2b69d2df.753636",
"2442314b13d75244"
]
]
},
{
"id": "2b69d2df.753636",
"type": "ui_template",
"z": "54a8ecc484312545",
"group": "165e1e1a.e752fa",
"name": "",
"order": 2,
"width": 0,
"height": 0,
"format": "",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 630,
"y": 680,
"wires": [
[
"ea3caac460682f1b"
]
]
},
{
"id": "2442314b13d75244",
"type": "debug",
"z": "54a8ecc484312545",
"name": "debug 5",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "template",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 620,
"wires": []
},
{
"id": "ea3caac460682f1b",
"type": "debug",
"z": "54a8ecc484312545",
"name": "debug 4",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 820,
"y": 680,
"wires": []
},
{
"id": "165e1e1a.e752fa",
"type": "ui_group",
"name": "Default",
"tab": "f9b58883.fa613",
"order": 1,
"disp": true,
"width": "12",
"collapse": false
},
{
"id": "f9b58883.fa613",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]