Legend TOC Not Building

Discussion created by shepa006 on Jul 23, 2013
I'm using the TOC widget from so that I can combine the table of contents and legend. It works great except that I recently noticed that once in a while it builds the TOC and fails to populate it (i.e. the layer divs are added but they're empty; <div id="agsjs_dijit__RootLayerTOC_0" widgetid="agsjs_dijit__RootLayerTOC_0"></div> instead of having the additional data within that div for each layer.

Has anyone encountered this problem before? It's not consistent (sometimes it loads the TOC perfectly) so I'm having a hard time tracking down the error. In my code the build is first connected to the map by dojo.connect(map, 'onLayersAddResult', function (results) which fires a function to test that each layer has been loaded app.layers[propt].loaded. Then if all layers come back as loaded it configures the TOC and starts it. I can't figure out why it's not always building correctly.