Global functions - workds from app.js, fails from everywhere else

You must Login before you can answer or comment on any questions.

I have a file called "core.js" which resides in /Resources/includes directory. And the file holds one simple function:

(function(){
    GetPath = function () {
        var Path;
        // If something bla bla bla
        return Path;
    }
})();
And then include it in app.js like this: Ti.include('includes/core.js');

Calling this function in "app.js" works fine, but then I tried to include the "core.js" file in the same manner in "/Resources/ui/common/SomeFile.js" and uppon callong the "GetPath()" function I get an error: Uncaught ReferenceError: GetPath is not defined.

1 Answer

I think you include the file with the wrong path.

If core.js is in "resources/includes/" then use the following code to include it in every file: Ti.include('/includes/core.js');

-- Joscha

Your Answer

Think you can help? Login to answer this question!