"Deploy" disabled after changes to node config using UI

Hello,

I made a custom node with some config properties... When from the UI I change one value of the config and I press "Done", the Deploy button is not enabled. BTW my custom nodes receive the config values.

Do I need to trigger manually some event to notify NodeRED that I need the Deploy button enabled?

Thanks.

Hi @fabiobeoni

in general, no, you do not need to trigger anything manually. The editor compares the node configuration before and after it has been edited and will enable the deploy button if it detects any changes.

Are you sure your custom node is applying the changes properly?

That's how I configure my property and read the value...

// I have a "dataref" typed input

 <div class="form-row">
        <label for="node-input-dataref"><i class="fa fa-tag"></i> Data Ref</label>
        <input type="text" id="node-input-dataref">
 </div>


// registering the node

defaults: {
        dataref: {
            required:false
        }
}

dataref:function (){
        return this.dataref;
},

oneditprepare:function (){
  const $dataRefInput = $('#node-input-dataref');

  $dataRefInput.typedInput({
            type:"json",
            types:["jsonata", "json"]
   });

  // set defaults and read the value on change
   $dataRefInput.typedInput('value', this.dataref || '');
   $dataRefInput.on('change',()=> this.dataref = $dataRefInput.val());
   this.dataref = $dataRefInput.val();
}

What is this supposed to be doing?

I think you are attempting to declare dataref as a function in this scope? That is not necessary. By defining dataref in the defaults, this.dataref it is generated for you.

I though they were required... getters.

BTW removing them does not resolve the issue :frowning:

Try...

 <div class="form-row">
        <label for="node-input-dataref"><i class="fa fa-tag"></i> Data Ref</label>
        <input type="hidden" id="node-input-datarefType">
        <input type="text" id="node-input-dataref">
 </div>
defaults: {
    dataref: {
       required:false
    }
},
oneditprepare:function (){
   $('#node-input-dataref').typedInput({
       type:"json",
       types:["jsonata", "json"],
       typeField: $("#node-input-datarefType")
   });
}

nope :frowning:

Why do I need an input hidden?

It is used to maintain state without you having to get/set the value manually.

Is your code on a repository somewhere?

Yeah, I forgot to add a default for the type & to add a value property in the dataref...

defaults: {
    dataref: {
       value: '',
       required:false
    },
    datarefType: {
        value: 'json'
    }
},
oneditprepare:function (){
   $('#node-input-dataref').typedInput({
       type:"json",
       types:["jsonata", "json"],
       typeField: $("#node-input-datarefType")
   });
}

I got it...

Basically the on change handler made the issue...

$dataRefInput.on('change',()=> this.dataref = $dataRefInput.val());

Looks like you don't need to look up for changes by your self, NodeRED does that in your behalf. So, due to the value update this.dataref = NodeRED didin't see any change in its own value compare checking algoritm.

That is why my example code excluded it

... and why I said ...

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