Client JS in the node config editor?

I'm the author of the node-red-contrib-mytimeout node. A user has noted a problem with the config (string vs number). I've figured out if I add a check box in the config editor I can have the user select what they need. Now I'd like to add some client JS to the config editor but I'm not sure how to do that. Any pointers?

I'm not really sure what you intend to do, but usually the existing nodes are great examples of what can be made possible in the various corners of Node-RED. You'll find the source of these nodes in their GitHub repo.

My thinking is to check that the on and off values are not the same and if they are then just warn the user (turn the 2 fields red). There might be a reason I hadn't thought of for having the values the same.

In order to do that you need to define validate functions for the attributes.
This documentation might help: Node properties : Node-RED

Working example from my own node is here.

2 Likes

An important point in the documentation is that

this can be used to access other properties of the node. This allows the validation to depend on other property values. While editing a node the this object reflects the current configuration of the node and not the current form element value. The validator function should try to access the property configuration element and take the this object as a fallback to achieve the right user experience.

So, each value can be tested against both the saved and the newly entered value of the other parameter, but I've found that getting the logic and ui correct can be tricky.

Huge thanks, forgot about those. :slight_smile:

1 Like

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