Note that there are some explanatory texts on larger screens.

plurals
  1. PODojo AMD module changes reference of "this"
    text
    copied!<p>I'm really confused as to some behavior I'm seeing in trying to learn the AMD style of Dojo. When I instantiate my module/object, "this" refers to the object in my constructor. I make a call to an internal function, and "this" inside that internal function refers to the Window object. So when I get to this.attachMapEventHandlers I get a "Object [object global] has no method 'attachMapEventHandlers'" error. What am I doing wrong? UPDATE: I found lang.hitch, which seems to indicate that the async nature is what's tripping me up, but I'm confused on how to implement a solution.</p> <p>my script inside index.html:</p> <pre><code>require(["javascript/layout", "dijit/layout/ContentPane", "dijit/layout/BorderContainer", "dijit/layout/AccordionContainer", "dojo/dom", "dojo/dom-attr", "dijit/Toolbar", "dijit/form/Button", "dijit/Dialog","dijit/ProgressBar", "dojo/domReady!"], function (layout, dom, domAttr) { mapControl = new layout(); </code></pre> <p>layout.js:</p> <pre><code>define(["dojo/_base/declare"], function(declare) { return declare(null, { action:"pan", activeMeasureTool:"", aerialLayer:"", legendLayers:"", loadedServices:"", popup:"", resizeId:0, constructor: function() { this.init(); }, init: function() { require(["esri/map", "esri/config", "esri/SpatialReference", "esri/geometry/Extent"], function(Map, config, SpatialReference, Extent) { //custom map requires a proxy to function properly. esri.config.defaults.io.proxyUrl = "../sdc_devdata/proxy.php"; var spatRef = new SpatialReference(2276); var startExtent = new Extent(2481416.32087491, 6963246.42495962, 2501196.36936991, 6980267.92469462, spatRef); var appFullExtent = new Extent(2396699.46935379, 6872369.60195443, 2607745.94404633, 7107335.22319087, spatRef); map = new Map("map", {extent: startExtent, isZoomSlider:true, logo:false, sliderStyle:"large"}); this.attachMapEventHandlers(); this.createLayers(); this.handleLayerVisibilityChange(); }); }, </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload