Input Field Values Lost on Node Red Page Refresh

386 views
Skip to first unread message

Patrick Perte

unread,
Sep 19, 2017, 4:26:39 PM9/19/17
to Node-RED
For the past few days I've been working on making my first custom node (yay!) and after reading over the code of the default nodes in an attempt to see how Node Red makes their code works, there's one problem I can't seem to solve. After a user enters in the name of the node, they have a few other input fields where they can type in the name and property of an object that they wish to compare. After entering in the data, they can close the node and continue working knowing that the node will remember the text that they entered. However, if they refresh the page, the node's label and input values disappear! Does anyone know of the proper way to store the values of the input fields so that even after a restart/refresh they will persist? The picture below could help with my explanation:

Essentially after a user hits Done and refreshes the page, all fields remain empty and the dropdown menu's are reset to their default value.

Nick O'Leary

unread,
Sep 19, 2017, 6:42:11 PM9/19/17
to Node-RED Mailing List
Hi Patrick,

Have you read the docs on the subject: https://nodered.org/docs/creating-nodes/node-html#edit-dialog ?

At its most basic, the editor works by looking for inputs in the edit dialog whose names correspond with the properties the node's definition declares. It then automatically gets and sets those inputs/properties as the dialog is opened and closed. (How the properties correspond to inputs is described in the docs).

You can do more complex things by defining an 'oneditprepare' and 'oneditsave' pair of functions - these get called when the dialog is opened and closed respectively - allowing you to write custom code to update the edit dialog on open, and update the node config on save.

Nick




--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/494ba8ef-1663-4522-82ea-d63ab434f661%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Patrick Perte

unread,
Sep 20, 2017, 11:58:48 AM9/20/17
to Node-RED
Thanks Nick, the link really helped. Turns out I forgot to put the node-input-<name> id to all of my input fields.
Reply all
Reply to author
Forward
0 new messages