How to use AMD radio button to control the ???turn on/off??? function of several layers

Discussion created by steven.lzhou on May 1, 2014
Latest reply on May 5, 2014 by steven.lzhou
I need to create a radio button to control the �??turn on/off�?? function of several layers.  The ESRI sample below provides a Legacy codes, but what I need is AMD style.

Here is the code I build so far, radio button just can not show up in my �??toggle2�?? div.  Any hints will be great help. Thanks!

             var selectLayers = [];
                      //river and feature4 are two layers I already created
                       selectLayers.push({ layer: rivers, title: "Rivers" });
                       selectLayers.push({ layer: feaLayer4, title: "Cities and Places" });
                       //var layerDiv = dojo.create("div");

                       arrayUtils.forEach(selectLayers, function (slayer) {

                           radioName = slayer.title;
                           alert("The Radio Button Name is  " + radioName); //This is to test my radio button name is correct
                           var radioButton = new RadioButton({
                               "checked": slayer.layer.visible,
                               "name": "radioButton" +,

                           }); // new RadioButton() ends here 

                           //Add Radio Button to the page
                 , "toggle2", "after");
                           var radioLabel = domConstruct.create('label', {
                               innerHTML: radioName,
                           }, radioButton.domNode, "after");
                 "<br/>", radioLabel, "after");
                       }); // Radio Button forEach( ) ends here