15. Adding Logic to a Button Node
In order to add logic into our button node, we will add an inject node, a function node, and two change nodes. This will allow us to change the color and the icon of the button when pressed.
Next, double-click on the function parameter, type the following code and parameters
1
var state = context.state || false;
2
state = !state;
3
context.state = state;
4
if (state) { return [msg,null]; }
5
else { return [null,msg]; }
6
Copied!
Click Done once completed
Next, double-click on the top change (1) node and change the following parameters
1
<i class="fa fa-rotate-90 fa-folder-open-o"></i> OPENED FEEDER
Copied!
Click Done once completed
Next, double-click on the top change (2) node and change the following parameters
1
<i class="fa fa-rotate-90 fa-folder-o"></i> CLOSED FEEDER
Copied!
Click Done once completed
Next, double-click on the inject node and change the following parameters
Click Done once completed
Next, connect all the nodes as shown below
Click Deploy and go to your Dashboard page
Congratulations, you have successfully built your dashboard!
Last modified 1yr ago
Copy link