DLee
DLee

Reputation: 300

Windows 8 Metro App: Cross Reference JS function from different files

I am having trouble cross reference JS function from one to another. I think the suggested way to write a Metro Style App is that you put your function in (function () {//code here})() from Microsoft. I couldn't really find anything related to this matter from MS, does anyone know how to do it?

Thanks in advance!

Upvotes: 0

Views: 405

Answers (1)

Dominic Hopton
Dominic Hopton

Reputation: 7292

You need to include the source file in the page before you call the function is in the other file.

You can create classes etc using WinJS.Class.define, as well as namespaces:

WinJS.Namespace.define("My.NameSpace", {
    MyClass: WinJS.Class.define(function myConstructor() {
    }, {
       myMemberVar: 1,
       myMemberFn: function (param) {
       }
     }
});
var f = new My.Namespace.MyClass();

You can then include that file before somewhere else that references it, and call it as you see fit.

Upvotes: 1

Related Questions