# Disabling template\_ui node causes its content to disappear

**URL:** https://discourse.nodered.org/t/disabling-template-ui-node-causes-its-content-to-disappear/9580
**Category:** Dashboard
**Created:** [29 March 2019 14:53 UTC](https://discourse.nodered.org/t/disabling-template-ui-node-causes-its-content-to-disappear/9580 "2019-03-29T14:53:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![allebarbieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allebarbieri/32/7116_2.png) [@allebarbieri](https://discourse.nodered.org/u/allebarbieri)
#### Post date: [29 March 2019 14:53 UTC](https://discourse.nodered.org/t/disabling-template-ui-node-causes-its-content-to-disappear/9580/1 "2019-03-29T14:53:45Z")

</div>

I noticed that enabling/disabling template nodes becomes not usable if template gets some input from msg.payload  
For example the following flow, uses a template to generate a list of text inputs starting from an array of labels in msg.payload.

```auto
[{"id":"51c73d95.d5dee4","type":"inject","z":"4f276a09.ba5e54","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":180,"wires":[["7d6301b7.dd766"]]},{"id":"4ea090a1.32f02","type":"inject","z":"4f276a09.ba5e54","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":280,"wires":[["40764ebe.e362"]]},{"id":"40764ebe.e362","type":"function","z":"4f276a09.ba5e54","name":"Set enabled property","func":"msg = {enabled:msg.payload};\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":300,"wires":[["72f913cd.fd7c8c"]]},{"id":"d4372db5.efb27","type":"inject","z":"4f276a09.ba5e54","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":320,"wires":[["40764ebe.e362"]]},{"id":"72f913cd.fd7c8c","type":"ui_template","z":"4f276a09.ba5e54","group":"a2a7a98e.efd6b8","name":"","order":4,"width":"6","height":"9","format":"<div ng-repeat=\"row in msg.payload\">\n <label>{{row}}</label>\n <input style=\"width:100%;\" ng-model-options=\"{ debounce: 200 }\" ng-model=\"i[$index]\" ng-change=\"out.payload = {val : i[$index], index : $index}; send(out)\"><br>\n</div>\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":720,"y":180,"wires":[[]]},{"id":"7d6301b7.dd766","type":"function","z":"4f276a09.ba5e54","name":"create label array","func":"msg.payload = [\"Label1\",\"Label2\",\"Label3\"];\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":180,"wires":[["72f913cd.fd7c8c"]]},{"id":"a2a7a98e.efd6b8","type":"ui_group","z":"","name":"Template group","tab":"5b337e3b.68826","order":2,"disp":true,"width":"6","collapse":false},{"id":"5b337e3b.68826","type":"ui_tab","z":"","name":"Home","icon":"home","order":1}]

```

 ![Picture1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/165723c7b2c19fa23bd8e48d16a34246b24709c9.png)

When you try to dynamically enable/disable using msg.enabled = true/false, the content disappears.

I think it is related [to the following quote of the dashboard documentation](https://flows.nodered.org/node/node-red-dashboard): 🧐

> Any widget can be disabled by passing in a `msg.enabled` property set to `false;` . _Note:_ this doesn't stop the widget receiving messages but does stop inputs being active **and does re-style the widget**.

The re-style causes the template to evaluate again the message.payload, which is not present in the enable message.  
Is there any way to overcome this behavior?

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [29 March 2019 15:09 UTC](https://discourse.nodered.org/t/disabling-template-ui-node-causes-its-content-to-disappear/9580/2 "2019-03-29T15:09:53Z")

</div>

add the content into the enable message?

Just as you would send the data on Node-RED startup to populate the dashboard, can't you in a enable message also include the dashboard data.

---

<div class="post-metadata">

### Author: ![allebarbieri](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allebarbieri/32/7116_2.png) [@allebarbieri](https://discourse.nodered.org/u/allebarbieri)
#### Post date: [29 March 2019 15:20 UTC](https://discourse.nodered.org/t/disabling-template-ui-node-causes-its-content-to-disappear/9580/3 "2019-03-29T15:20:45Z")

</div>

In general the payloads and enables messages can be completely uncorrelated and generated at different times.

However, when payload is generated it could be saved it in some context variable, and retrieved when the enable/disable message are generated.

👺 It doesn't seem very elegant but it should work!
