Function call from one js file to another

Hi,

I'm working on the node-red deploy button, trying to invoke the save() function in deploy.js file on click of the event(tab) from the tabs.js file, But the save() function has a lot of other functions involved in it, and those functions are within the deploy.js file only.

How do I call one js file from another js file (deploy.js file from tabs.js file)
and How do I invoke a function from one js file from another js file

Hi @Syedabd

you cannot do that. The tabs.js file you are editing is a common component that is reused in multiple places in the editor. It is not meant to have any Node-RED specific functionality in it.

Likewise deploy.js contains all the logic for the deploy button. It is meant to be a self-contained component, so doesn't expose anything directly to other parts of the editor.

Given the level of customisation you are doing, you are of course free to expose whatever functions you want from deploy.js. So, for example, at the bottom of that file you'll see it returns an object of functions (init and setDeployInflight). If you really must, you could add save to that object so you can call it as RED.deploy.save()

Can I ask why you want to move the deploy button into the tab bar? I assume you are making a very custom version of Node-RED here...? With the sorts of changes you are making it will be hard for you to keep current with new versions of Node-RED - I assume you're happy with that?

Thanks a bunch, @knolleary.Yes I'm trying to customize for some of the requirements.

For tabs I see addClass("red-ui-tabs");, but what is the source for the button in node-red.Can you please let me know ? I'm not able to get the button

I'm not sure what you mean. 'red-ui-tabs' is a CSS class name. It's just one part of many pieces it takes to make the UI component.

Similarly, red-ui-button is just a CSS class name to make an element look like a button. You would apply it to a <a> or <button> element - but you should be able to see all of that for yourself from the code you are changing.

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