# Notify on Click

**URL:** <https://discourse.nodered.org/t/notify-on-click/42754>\
**Category:** Dashboard\
**Created:** [17 March 2021 07:32 UTC](https://discourse.nodered.org/t/notify-on-click/42754 "2021-03-17T07:32:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkuehn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vkuehn/32/34805_2.png) [@vkuehn](https://discourse.nodered.org/u/vkuehn)\
**Post date:** [17 March 2021 07:32 UTC](https://discourse.nodered.org/t/notify-on-click/42754/1 "2021-03-17T07:32:07Z")

</div>

Dashboard Buttons work fine. I just have some slow things reacting on the click.

Would it be Possibly to add some flash/color change reaction to the Dashboard Button for the onClick Event ?

Also disabling buttons for a while would be a solution if possible ?

---

<div class="post-metadata">

**Author:** ![vkuehn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vkuehn/32/34805_2.png) [@vkuehn](https://discourse.nodered.org/u/vkuehn)\
**Post date:** [17 March 2021 14:09 UTC](https://discourse.nodered.org/t/notify-on-click/42754/2 "2021-03-17T14:09:14Z")

</div>

oh found it, thought an old example which still works ok

```auto
[{"id":"b9a70965.13e138","type":"ui_button","z":"d511095d.512808","name":"","group":"c070ecdb.6d5ce","order":0,"width":"0","height":"0","passthru":false,"label":"{{payload}}","color":"","bgcolor":"{{colour}}","icon":"","payload":"press","payloadType":"str","topic":"","x":610,"y":560,"wires":[["48aaee20.8d9e1"]]},{"id":"5cc84101.ac6d9","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"<i class=\"fa fa-rotate-90 fa-folder-open-o\"></i> OPEN","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":520,"wires":[["b9a70965.13e138"]]},{"id":"329e773b.0fdcb8","type":"inject","z":"d511095d.512808","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":190,"y":560,"wires":[["bc5a70e.6f6a29"]]},{"id":"48aaee20.8d9e1","type":"function","z":"d511095d.512808","name":"state","func":"var state = context.state || false;\nstate = !state;\ncontext.state = state;\nif (state) { return [msg,null]; }\nelse { return [null,msg]; }\n","outputs":2,"noerr":0,"x":190,"y":700,"wires":[["5cc84101.ac6d9"],["bc5a70e.6f6a29"]]},{"id":"bc5a70e.6f6a29","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"<i class=\"fa fa-rotate-90 fa-folder-o\"></i> Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":560,"wires":[["b9a70965.13e138"]]},{"id":"c070ecdb.6d5ce","type":"ui_group","z":"d511095d.512808","name":"Click","tab":"7d974e73.cf8f9","order":1,"disp":true,"width":"5"},{"id":"7d974e73.cf8f9","type":"ui_tab","z":"d511095d.512808","name":"Home","icon":"link","order":1}]

```

example was made by dceejay in slack 2018

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [17 March 2021 14:57 UTC](https://discourse.nodered.org/t/notify-on-click/42754/3 "2021-03-17T14:57:29Z")

</div>

> [@vkuehn](#):
>
> still works ok

You might use the newer (although the older one still works) syntax for the context. In such case your function code would looks like:

```auto
var state = context.get("state") || false;
state = !state;
context.set ("state" , state);

if (state) { return [msg,null]; }
else { return [null,msg]; }

```

---

<div class="post-metadata">

**Author:** ![vkuehn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vkuehn/32/34805_2.png) [@vkuehn](https://discourse.nodered.org/u/vkuehn)\
**Post date:** [17 March 2021 15:45 UTC](https://discourse.nodered.org/t/notify-on-click/42754/4 "2021-03-17T15:45:29Z")

</div>

ok thanks Andrei, I'll try that

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 April 2021 15:45 UTC](https://discourse.nodered.org/t/notify-on-click/42754/5 "2021-04-16T15:45:35Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
