Call one js-function from another file

Hi!

Is it possible to call a javascript function in A.js from B.js ?

I want to make a global file called Pages.js which all the functions for page-transitions and changing pages is inside.
Is it possible ?

I’ve tried this, but the app crashes without any error message :slight_smile:

MainView.ux

<App>
	<JavaScript File="JS/Pages.js" ux:Global="Pages"/>
	<JavaScript File="JS/Login.js" />

	<ClientPanel>

		<PageControl Active="{currentPage}">
			<Login Name="Login" /> 
			<Start Name="Start" />
		</PageControl>
		
	</ClientPanel>
</App>

Pages.js

  var Observable = require("FuseJS/Observable");
  var currentPage = Observable("Login");
  function changePage(name) {
  	currentPage.value = name;
  }
  module.exports = {
  	currentPage: currentPage,
  	changePage : changePage
  };

Login.js

var Pages = require("Pages");


function login (){
    Pages.changePage("Start");
}


module.exports = {
 login: login
};

<JavaScript File="JS/Pages.js" ux:Global="Pages"/>

This approach for using JS files was deprecated quite some time ago and won’t work.

Check this for instructions on how to properly include JS modules (basically you just bundle them in the .unoproj and then require).