Thanks Robert! That worked great.
The esri layerlist works fine for a layer created as an ArcGISDynamicMapService. However, I have a service that has a main layer with several sublayers.
eg. MainLayer (0)
SubLayerA (1)
SubLayerB (2)
If I define my layer as a FeatureLayer in JavaScript using this service (ex ...myservice/MapServer/0 ), it does not work. I have to point the FeatureLayer to one of the SubLayers (1 or 2) in order for the esri layerlist to work. And then it only works for that one layer. Is there any way to make the esri layerlist show all of the sublayers when using a FeatureLayer instead of an ArcGISDynamicMapService?
I have sublayers set to "true" but that does not seem to work for anything defined as a FeatureLayer.
Thanks.