Solved! Go to Solution.
map.on("layers-add-result", initEditor);
function iniEditor(results){
//the same code as you already have to build layerInfos in settings.
var editor = new new esri.dijit.editing.Editor(params,'editorDiv');
editor.startup();
//when a layer is removed from the map, recreate the editor widget
map.on("layer-remove", dojo.hitch(null, recreateEditor, editor));
}
function recreateEditor(editor){
editor.destroy();
editor = new new esri.dijit.editing.Editor(params,'editorDiv');
editor.startup();
}