RED.sidebar plugin UI updation from JS file

Hello All,

I have created a custom plugin to Node-Red Editor to add my tab to sidebar.
I referred:

I have two files in plugin:
testplugin.html

I have created a drop down list like this:


    var x = document.createElement("SELECT");
    x.setAttribute("id", "mySelect");
    document.body.appendChild(x);

    var z = document.createElement("option");
    z.setAttribute("value", "css");
    var t = document.createTextNode("CSS");
    z.appendChild(t);
    document.getElementById("mySelect").appendChild(z);

testplugin.js

In js I am having HTTP listener like this:

On getting any data on /chatgpt I want to update my drop-down list which I created in HTML file dynamically.

Can you please help me how can I do this ?

You already have the done callback in your call to the /chatgpt API endpoint, that is where you update your drop-down. You should also include a fail callback so that you can notify the Editor when the call fails for whatever reason.

Hello @TotallyInformation ,
Thank you for reply.

Yes, that is true.
But when I am trying to do access that dropdown in js file, it is not able to do so.
I tried : document.getElementById("id of dropdown");

No, you have to do it in the Editor not in the runtime.

It is in the editor that you trigger your API call and get the response in the done function so that is where you update the drop-down.

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