[RESOLVED] Clear Text Input Field after Sending

#1

Hello,
Hoping someone can help with this. My dashboard has several text input fields that I would like to return to their default state (null) after sending the payload. For my use, I have the text input mode set to number, and the delay is 0.

What I am trying to accomplish is if a user enters 400 and presses the return key, 400 is sent as the message payload and the input field returns to its default state with no entry. What is happening is that the field retains the value, in this case, 400. It is also persistent through a browser refresh.

I have been able to inject a new payload into the text field, for instance, 0 but I have not been able to get this to happen automatically and I would prefer it not have a value at all. I tried connecting the output of the text input to a function, the function then sets a new payload but the text input does not display this new payload. What's odd is that the dashboard refreshes when the payload is injected but not when passed in from a function.

Thanks in advance for your help!

Update:
Using a change node and changing the payload to a number set to null clears the text input box on a browser refresh but it doesn't update the dashboard in real time. Tried deleting msg._msgid and all other keys, still wouldn't update the browser in realtime.

The odd thing is that an inject node set to number null does update the browser in realtime.

Viewing the entire msg object in debug and the message created by the change node and inject node look virtually identical (except for _msgid)

What could be different that causes an inject to update the text input in realtime?

Solved:
Adding a delay node before the change node that sets payload to number null now resets the text input node on the dashboard in real time.

Hope this helps someone!

2 Likes

#2

Can you possibly share the code (only the part that concerns this explanation) ? Thanks.

0 Likes

#3

Here is an example of the text input, delay and change nodes used to clear the text input field.

[{"id":"8377ea1f.4f67f8","type":"ui_text_input","z":"f5c1f0be.c813d","name":"oilTarget","label":"Oil Temp","group":"a517da34.afeac8","order":3,"width":"3","height":"1","passthru":false,"mode":"number","delay":"0","topic":"oilTarget","x":200,"y":1160,"wires":[["d9d899e9.7e47d","6e79b03e.55b618"]]},{"id":"a1ae28d9.0d25","type":"change","z":"f5c1f0be.c813d","name":"Clear Value","rules":[{"t":"set","p":"payload","pt":"msg","to":"null","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":1240,"wires":[["8377ea1f.4f67f8"]]},{"id":"6e79b03e.55b618","type":"delay","z":"f5c1f0be.c813d","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":120,"y":1240,"wires":[["a1ae28d9.0d25"]]},{"id":"a517da34.afeac8","type":"ui_group","z":"","name":"Manual Control","tab":"a312bb8e.67b4","order":3,"disp":true,"width":"18","collapse":true},{"id":"a312bb8e.67b4","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
0 Likes

#4

Interesting. It would work even if you set the number to "cookies" (instead of null). As a matter of fact the change node is not generating a null but a NaN (not a number). It works as NaN is ultimately a numeric value.

r-01

0 Likes

#5

Yes, seems like an odd workaround but it appears to work :grinning:

0 Likes