Hi everyone
I have a select input with 2 customs value and one string value. When I put the value "type" in the "defaults" and that the click on my node, the node editor is empty while when I put in comment the value "type" it is not anymore but the select does not keep the value in memory while the other fields work very well.
Thank you in advance for your help
<script type="text/javascript">
RED.nodes.registerType('Message',{
category: 'matrice_svi',
color: '#A1EEBD',
defaults: {
//type: {value:""},
//static
condition: {value:""},
file: {value:""},
tts:{value:""},
//complex
value:{value:""},
interpretAs:{value:""},
inputFormat:{value:""},
format:{value:""},
fonction:{value:""}
},
inputs: 1,
outputs: 1,
icon: "icons/icon.svg",
label: function() {
return this.name||"Message";
},
oneditprepare: function() {
var static = {
value: "static",
label: RED._("node-red:static"),
hasValue: false
};
var complex = {
value: "complex",
label: RED._("node-red:complex"),
hasValue: false
};
$("#node-input-type").typedInput({
type:static,
types:[static,complex,"str"],
typeField: "#node-input-typeName"
})
$("#node-input-type").on("change", function(e) {
var val = $("#node-input-type").typedInput('type');
//static
console.log(val)
$(".static").toggle(val === "static");
$(".complex").toggle(val === "complex");
});
$("#node-input-type").change();
}
});
</script>
<script type="text/html" data-template-name="Message">
<div class="form-row">
<label for="node-input-type"><i class="fa fa-tag"></i>type</label>
<input type="text" id="node-input-type" placeholder="Chaine de caractère">
<!--<input type="hidden" id="node-input-typeName">-->
</div>
<!-----------------------------Static------------------------------------>
<div class="static">
<div class="form-row">
<label for="node-input-condition"><i class="fa fa-tag"></i>condition</label>
<input type="text" id="node-input-condition" placeholder="condition">
</div>
<div class="form-row">
<label for="node-input-file"><i class="fa fa-tag"></i>file</label>
<input type="text" id="node-input-file" placeholder="file">
</div>
<div class="form-row">
<label for="node-input-tts"><i class="fa fa-tag"></i>tts</label>
<input type="text" id="node-input-tts" placeholder="tts">
</div>
</div>
<!------------------------------Complex------------------------------------->
<div class="complex">
<div class="form-row">
<label for="node-input-interpretAs"><i class="fa fa-tag"></i>interpretAs</label>
<input type="text" id="node-input-interpretAs" placeholder="interpretAs">
</div>
<div class="form-row">
<label for="node-input-value"><i class="fa fa-tag"></i>value</label>
<input type="text" id="node-input-value" placeholder="value">
</div>
<div class="form-row" >
<label for="node-input-inputFormat"><i class="fa fa-tag"></i>inputFormat</label>
<input type="text" id="node-input-inputFormat" placeholder="inputFormat">
</div>
<div class="form-row">
<label for="node-input-format"><i class="fa fa-tag"></i>format</label>
<input type="text" id="node-input-format" placeholder="format">
</div>
<div class="form-row">
<label for="node-input-fonction"><i class="fa fa-tag"></i>fonction</label>
<input type="text" id="node-input-fonction" placeholder="fonction">
</div>
</div>
</script>