# Function call from one js file to another

**URL:** https://discourse.nodered.org/t/function-call-from-one-js-file-to-another/42811
**Category:** General
**Created:** [18 March 2021 11:44 UTC](https://discourse.nodered.org/t/function-call-from-one-js-file-to-another/42811 "2021-03-18T11:44:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Syedabd](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@Syedabd](https://discourse.nodered.org/u/Syedabd)
#### Post date: [18 March 2021 11:44 UTC](https://discourse.nodered.org/t/function-call-from-one-js-file-to-another/42811/1 "2021-03-18T11:44:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [18 March 2021 11:50 UTC](https://discourse.nodered.org/t/function-call-from-one-js-file-to-another/42811/2 "2021-03-18T11:50:51Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Syedabd](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@Syedabd](https://discourse.nodered.org/u/Syedabd)
#### Post date: [18 March 2021 12:38 UTC](https://discourse.nodered.org/t/function-call-from-one-js-file-to-another/42811/3 "2021-03-18T12:38:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [18 March 2021 13:22 UTC](https://discourse.nodered.org/t/function-call-from-one-js-file-to-another/42811/4 "2021-03-18T13:22:11Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [1 April 2021 13:22 UTC](https://discourse.nodered.org/t/function-call-from-one-js-file-to-another/42811/5 "2021-04-01T13:22:54Z")

</div>

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