AnsweredAssumed Answered

How to save object globally in a ArcGIS API For JavaScript Application?

Question asked by sanjayjadhav on Feb 13, 2015
Latest reply on Feb 15, 2015 by sanjayjadhav

Hello,

 

I have one question regarding creation of objects in a JavaScript Application in a modular development.

 

If I create any object, for example esri/map object one one AMD module, how to access it on some other module. Let's assume that in a HTML page, when a dom is ready, I call some some method from a module to create a map as below;

 

define(["esri/map",
        "dojo/on"], function (Map) {


    return {       
        createMap: function (mapDivID) {
            var map = new Map(mapDivID);
        }, //createMap ends
    };
});

 

Now, I call this function from my HTML page when the DOM is ready. However, I'm not being able to figure out how to access this map variable (map object) on another AMD module. I guess I need to save it globally but How?

 

Any help is much appreciated.

 

Cheers,

S.

Outcomes