Making app in Titanium, i am trying to call a function in another js file i made. i am tring to call function from my index.js. when i do so it cant find it. i think it is a scope issue. in java i would make an object of a class and do object.function(). im not sure how to go about it in JS. Or is it that i have to add my new JS file to a manifest someplace.
Asked
Active
Viewed 438 times
0
-
can you post some code? – Aaron Saunders Jun 20 '13 at 02:22
1 Answers
1
You can use Ti.include method for this. Suppose you have two files, index.js and common.js and you want to call a method initScreen()
that is defined in common.js. You can call the method inside index.js as follows
Ti.include("common.js"); //Write this at the top of your index.js
initScreen(); //As usual
You have another option is require method. If you are writing the common.js file as commonJS module, you can use require method
.
Hope it helped you

Anand
- 5,323
- 5
- 44
- 58
-
have you given the correct path? The above will work only if both common.js and index.js are in same folder – Anand Jun 25 '13 at 03:45