I am developing a node that is configured with a config node. In the .js file, I can access the config node using RED.nodes.getNode(n.config);
. How can I access the config node from the HTML?
My config node defines two fields keyName
and valueName
. In the actual node, I have a select field with the following two options:
<option value="key">key</option>
<option value="value">value</option>
I would like to change the text for these options based on the keyName
and valueName
properties of the currently selected config node.
I think the best way for doing so (but please correct me if I'm wrong) would be to have something like the following in the oneditprepare
function:
$("#node-input-config").change(function() {
// The following doesn't work on HTML, how can I get the config node in HTML?
var config = RED.nodes.getNode($(this).val());
$('#node-input-select option[value="key"]').text(config.keyName);
$('#node-input-select option[value="value"]').text(config.valueName);
});
$("#node-input-config").change();