Select to view content in your preferred language

Using AMD, connect throws an error.

1478
6
Jump to solution
04-23-2013 08:29 AM
JimWharton
Occasional Contributor
I'm attempting to connect to the map's onLoad event:

var map;       require(["esri/map", "esri/SpatialReference", "esri/geometry/Extent", "dojo/_base/connect", "app/populate", "dojo/ready"],         function(Map, SpatialReference, Extent, connect, populate, ready) {           ready(function() {             var initialExtent = new Extent({               xmax: -11241653.995873693,               xmin: -13198441.919973679,               ymax: 5178320.359930991,               ymin: 4453085.835561435,               "spatialReference": {                 "wkid": 102100               }});              map = new Map("mapDiv", {               extent: initialExtent,               basemap: "streets"             });              connect(map, "onLoad", function() {               populate.addPoints();             });           });        });   }


No matter what, I keep getting a JS error:

Uncaught TypeError: Object is not a function. 


I've tried replacing the call to populate.addPoints() with a simple console.log, and still, it errors on "connect". That's a pretty basic Dojo thing, so I'm confused about where the problem is. The examples page shows something nearly identical.
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Deactivated User
Use connect.connect() instead of connect().

The dojo/_base/connect module is not a single function but rather contains a couple of functions. For more detailed examples, look at the Dojo 1.7(AMD) section here:  https://dojotoolkit.org/reference-guide/1.7/dojo/connect.html

View solution in original post

0 Kudos
6 Replies
derekswingley1
Deactivated User
Use connect.connect() instead of connect().

The dojo/_base/connect module is not a single function but rather contains a couple of functions. For more detailed examples, look at the Dojo 1.7(AMD) section here:  https://dojotoolkit.org/reference-guide/1.7/dojo/connect.html
0 Kudos
JimWharton
Occasional Contributor
Excellent, that works. The docs may need a tweak to represent that gotcha.

Thanks!

-Jim
0 Kudos
derekswingley1
Deactivated User
You're welcome!

Where in the docs do we use connect()? It should be dojo.connect or connect.connect everywhere.
0 Kudos
JimWharton
Occasional Contributor
You're welcome!

Where in the docs do we use connect()? It should be dojo.connect or connect.connect everywhere.


http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/map-amd.html#onLoad

All examples on that page.

I appreciate your help.

-Jim
0 Kudos
derekswingley1
Deactivated User
Thanks Jim, we'll get those fixed.
0 Kudos
KenBuja
MVP Esteemed Contributor
Thanks Jim, we'll get those fixed.


Any update on when this will be fixed?

At the same time, could you also update the API reference so that the "AMD Module Require" version of the documentation shows "on" method in the code snippets and the new event names?
0 Kudos