on(map, "layers-add-result", function(e) { var toc = new agsjs.dijit.TOC({ map: map, layerInfos:legendLayers }, 'legendDiv'); toc.startup(); });
dojo.connect(map,'onLayersAddResult', function(results){ var toc = new agsjs.dijit.TOC({ map: map, layerInfos:legendLayers }, 'legendDiv'); toc.startup(); });
Solved! Go to Solution.
this.map = new Map("map", { infoWindow: popup, basemap: "streets", autoResize: true, sliderStyle: style, logo: false, showAttribution: false, lods: lods }); map = this.map; var tocAdder = map.on('layers-add-result', lang.hitch(this, function(results) { // alert('in onlayeradd'); if (!this.toc) { this.toc = new agsjs.dijit.TOC({ map: map, layerInfos: layerInfos.reverse() }, 'tocDiv'); toc = this.toc; toc.startup(); lang.hitch(this, createLegend());
map.on("layers-add-result", function(e) { ...
map.on("layers-add-result", function(e) { //stuff }); on(map, "layers-add-result", function(e) { //stuff });
Both are valid.map.on("layers-add-result", function(e) { //stuff }); on(map, "layers-add-result", function(e) { //stuff });
Does the event fire?
What happens when you wrap the problematic code in a try/catch?
Are you able to fire the event with a simple console.log in the function block, like in this jsfiddle?
http://jsfiddle.net/NcCWw/
*edit
Also, you should probably be creating the TOC object earlier on in your code (preferably before the parser runs). You can still start it up inside your event.
i have noticed similar issues with layers add
map.on works, on(map style does not
No. The event isn't fired. The error seems to be in attaching the event to the map.