I am having some problems with editing the Editor object. We have multiple layers that are editable by the user, and the user can enable and disable layers. When a layer is disable/enabled the Editor object should be modified or removed+created to make sure the layers are visible in the toolbar.
We have this method for creating the editor, but how could I modify the layers inside the editor (or templatepicker), when the object is allready initialized..
this.addToolbar = function(map, id, layers, featureLayers) {
if (dijit.byId(id)) {
//TODO Update existing editor if layers changed
} else {
var settings = {
map: map,
layerInfos: featureLayers,
createOptions: {
polylineDrawTools: [Editor.CREATE_TOOL_FREEHAND_POLYLINE],
polygonDrawTools: [Editor.CREATE_TOOL_FREEHAND_POLYGON,
Editor.CREATE_TOOL_CIRCLE,
Editor.CREATE_TOOL_TRIANGLE,
Editor.CREATE_TOOL_RECTANGLE
]
},
toolbarVisible: false,
toolbarOptions: {
reshapeVisible: true
}
};
var params = {
settings: settings
};
var myEditor = new Editor(params, id);
myEditor.startup();
}
}
So i could store the value of myEditor, but what variable do I change, and how do I make sure it updates the html? Any ideas?
Update: This is not the way to go, when i destroy a editor, the elements that are already drawn with it are not editable anymore. I will just show and hide the editors with some plain js.
1 Answer 1
Nest your editor node in another container.
<div id="editorContainer">
<div id="editor"> </div>
</div>
Move the settings and params before the if statement.
Then in the TODO part -
destroy the editor
myEditor.destroyRecursive();
recreate the editor div in the editorContainer
domConstruct.create("div",{id:"editor"},"editorContainer");
recreate the editor
var myEditor = new Editor(params, id);
-
Thanks for you reply. I found out that elements that are drawn with a toolbar are not editable anymore when that toolbar is re-created.. So i need to change the way the app works atm.Nico Bijl– Nico Bijl2015年02月13日 09:18:32 +00:00Commented Feb 13, 2015 at 9:18