Select to view content in your preferred language

dojo namespace change upsets loading of local modules

819
4
08-18-2010 05:48 PM
LorenMueller
Regular Contributor
Hi,
I can't get local modules to reload anymore with the namespace change.  In the code below I can not get into init_2 (I get cross-domain loading errors), though the in-line dijit is created just fine.  Hoping you can see where I have gone wrong without having to create your own test utility resource to try this one out.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>(esriDojo Testing)</title> 
   
    <!-- styling -->
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css"/>
                                
    <!-- Set dojo configuration -->
    <script type="text/javascript">
        djConfig = {
            isDebug: true,
            parseOnLoad: true,
            xdWaitSeconds: 10,
            scopeMap: [
                ["dojo", "esriDojo"],
                ["dijit", "esriDijit"],
                ["dojox", "esriDojox"]
            ],
            baseUrl: "./",
            modulePaths: {
                "MyModules": "./MyModules"
            }
        };
    </script>
   
    <!-- v2.0 uses Dojo v1.4.2 -->
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0"></script>
   
    <script type="text/javascript">
       
        esriDojo.require("dijit.form.DropDownButton");
        esriDojo.require("dijit.Menu");
        esriDojo.addOnLoad(init_1);
       
        function init_1() {
            console.log("in init_1()");
            esriDojo.require("MyModules.Utilities.MyTestUtility");
            esriDojo.addOnLoad(init_2);
        }
       
        function init_2(){
            console.log("in init_2()");
        }

    </script>
   
</head>
<body class="tundra">
   
    <button esriDojoType="dijit.form.DropDownButton">
    <span>Test DDBtn</span>
    <div esriDojoType="dijit.Menu">
        <div esriDojoType="dijit.MenuItem" label="Some menu item 1">
            <script type="dojo/method" event="onClick" args="evt">
                console.log("ok 1");
            </script>
        </div>
        <div esriDojoType="dijit.MenuItem" label="Some menu item 2">
            <script type="dojo/method" event="onClick" args="evt">
                console.log("ok 2");
            </script>
        </div>                  
    </div>
    </button>

</body>
</html>


Loren
0 Kudos
4 Replies
KellyHutchins
Esri Frequent Contributor
It's probably just a typo but thought I'd check just in case, in the code snippet below it looks like there's a space in Utility?

esriDojo.require("MyModules.Utilities.MyTestUtilit y");

Hi,
I can't get local modules to reload anymore with the namespace change.  In the code below I can not get into init_2 (I get cross-domain loading errors), though the in-line dijit is created just fine.  Hoping you can see where I have gone wrong without having to create your own test utility resource to try this one out.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>(esriDojo Testing)</title> 
   
    <!-- styling -->
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css"/>
                                
    <!-- Set dojo configuration -->
    <script type="text/javascript">
        djConfig = {
            isDebug: true,
            parseOnLoad: true,
            xdWaitSeconds: 10,
            scopeMap: [
                ["dojo", "esriDojo"],
                ["dijit", "esriDijit"],
                ["dojox", "esriDojox"]
            ],
            baseUrl: "./",
            modulePaths: {
                "MyModules": "./MyModules"
            }
        };
    </script>
   
    <!-- v2.0 uses Dojo v1.4.2 -->
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0"></script>
   
    <script type="text/javascript">
       
        esriDojo.require("dijit.form.DropDownButton");
        esriDojo.require("dijit.Menu");
        esriDojo.addOnLoad(init_1);
       
        function init_1() {
            console.log("in init_1()");
            esriDojo.require("MyModules.Utilities.MyTestUtility");
            esriDojo.addOnLoad(init_2);
        }
       
        function init_2(){
            console.log("in init_2()");
        }

    </script>
   
</head>
<body class="tundra">
   
    <button esriDojoType="dijit.form.DropDownButton">
    <span>Test DDBtn</span>
    <div esriDojoType="dijit.Menu">
        <div esriDojoType="dijit.MenuItem" label="Some menu item 1">
            <script type="dojo/method" event="onClick" args="evt">
                console.log("ok 1");
            </script>
        </div>
        <div esriDojoType="dijit.MenuItem" label="Some menu item 2">
            <script type="dojo/method" event="onClick" args="evt">
                console.log("ok 2");
            </script>
        </div>                  
    </div>
    </button>

</body>
</html>


Loren
0 Kudos
LorenMueller
Regular Contributor
Hi Kelly,
Yes, that was just a typo as I prepared my sample code for posting here.  My modules have different names and I put that there as example of my structure.
Other than the typo, any other ideas about the module mapping and why the local ones will not load?
Thanks, Loren
0 Kudos
JeffreyWilkerson
Frequent Contributor
Loren,  it must have something to do with what is in MyModules.Utilities.MyTestUtility.  I don't have access to that but when I remark that out everything seems to work fine.
0 Kudos
MichaelRollins
Emerging Contributor
We had to load a second version of dojo to get comet working, and at first we attempted to rename the esri dojo packages.  Unfortunately, that was not easily done, so we renamed the second version of dojo.  This worked out well.

My suspicion is that it has to do with the path in modulePaths.  Where does "./MyModules" point to?  If I understand how namespace changes work in dojo (which I may not completely) ./ may refer to something on ESRI's servers, not on your server.  The namespace rename will point to wherever the dojo version is hosted, and in this case, it points to ESRI's server.  Try putting in a absolute URL and see if that clears it up.

[EDIT]

If you're attempting to load something on ESRI's servers, you would get a cross site scripting error, so this makes a lot of sense.  The xss error may be coming from the require call.
0 Kudos