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">
dojo.addOnLoad(init);
</script>
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:
dojo.require("esri.map");
dojo.require("esri.layers.graphics");
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("http://toqgis.queensbury.net/ArcGIS/rest/services/webapp3/MapServer", {
"opacity": 0.5,
});
map.addLayer(qbydynamLayer);
})
})
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.