AnsweredAssumed Answered

dojo addonload transition to AMD

Question asked by ghilton on Oct 1, 2014
Latest reply on Oct 1, 2014 by ghilton

I have a question on transitioning to AMD references and calling an initial function when an application loads.


Currently my pre AMD application contains the following line in my default.aspx:


<script type="text/javascript">




the init function is in a separate load.js file included in my visual studio web application.  At the top of the load.js file I list several requirements, example:





then the init function begins which adds layers to the map.




I am trying to rewrite my code with AMD references like this:


require(["esri/Map", "esri/geometry/Extent", "dojo/ready",

                    "dojo/domReady!"], function (Map, Extent, registry, ready) {

                        ready(function () {

                           var initExtent = new Extent({ "xmin": -8227830.3637063, "ymin": 5340700.39573648, "xmax": -8171280.30528049, "ymax": 5394550.12077208, "spatialReference": { "wkid": 102100 } });

                            map = new Map("map", { extent: initExtent, slider: false, logo: false });



                            var qbydynamLayer = new esri.layers.ArcGISDynamicMapServiceLayer("", {

                                "opacity": 0.5,







I placed this code in the load.js file to replace the init function and it is not working.  I'm sure it's an easy fix, but I cannot seem to find a way to call this code from default.aspx with code similar to the old   dojo.addOnLoad reference.


Any help is appreciated.  Thanks in advance.