<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cannot start editing with button in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510322#M47493</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry to revive an older thread, but I found the thread while debugging a similar activate editing button in my app.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a 'Done' button in the container with my editor that turns the editor off, and then a menu selection that turns editing on.&amp;nbsp; When the user clicks 'Done' I call 'editorWidget.destroy()' and remove the DOM nodes.&amp;nbsp; When the editor is reactivated I recreate the nodes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, in my console, I get an error message - "Tried to register widget with id==editorDiv but that id is already registered".&amp;nbsp; I thought calling destroy() prevents that from happening?&amp;nbsp; The editor seems to work despite the error, but I don't want this error to display to users.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts on this?&amp;nbsp; Thanks, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Apr 2013 13:57:24 GMT</pubDate>
    <dc:creator>JamesTrier</dc:creator>
    <dc:date>2013-04-26T13:57:24Z</dc:date>
    <item>
      <title>Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510319#M47490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am attempting to start and stop an edit session using two buttons within a web app.&amp;nbsp; The edit session begins, but I have to click the "Start Editing" button twice to have it start.&amp;nbsp; The edit session will stop when I click the "Stop Editing" button, but then I am unable to start another edit session.&amp;nbsp; Does anyone know why both of these issues may be occurring?&amp;nbsp; Below is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var editorWidget;&amp;nbsp; function startEditing(){ &amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayers(editLayers); &amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.connect(map, "onLayersAddResult", initEditing); }&amp;nbsp; function stopEditing(){ &amp;nbsp;&amp;nbsp;&amp;nbsp; editorWidget.destroy(); }&amp;nbsp; function initEditing(results) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var featureLayerInfos = dojo.map(results, function(result) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "featureLayer": result.layer &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var settings = { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map: map, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerInfos: featureLayerInfos &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var params = { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; settings: settings &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; editorWidget = new esri.dijit.editing.Editor(params, 'editorDiv'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var options = {snapKey:dojo.keys.copyKey}; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.enableSnapping(options); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; editorWidget.startup(); }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 18:33:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510319#M47490</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-02-21T18:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510320#M47491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've found that when you call destroy(), it also deletes the container div you put the editorWidget in, 'editorDiv' in your case. So when you call editorWidget.startup() after a destroy, it has no place to put it since 'editorDiv' no longer exists. You'll need to re-append editorDiv into the DOM before calling editorWidget.startup() if you want to start editing again after a destroy() call.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 16:09:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510320#M47491</guid>
      <dc:creator>RyanKoehnen</dc:creator>
      <dc:date>2013-03-22T16:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510321#M47492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ryan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply.&amp;nbsp; You are right, the div was being deleted after calling destroy().&amp;nbsp; I updated the stopEditing function to recreate the div:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function stopEditing(){
&amp;nbsp;&amp;nbsp;&amp;nbsp; editorWidget.destroy();&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.create("div", {id: "editorDiv"}, "leftPane");
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure why I have to click Start Editing twice to begin the initial edit session, but each stop/start of the edit session works with no problems after that.&amp;nbsp; Thanks for the help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510321#M47492</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T22:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510322#M47493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry to revive an older thread, but I found the thread while debugging a similar activate editing button in my app.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a 'Done' button in the container with my editor that turns the editor off, and then a menu selection that turns editing on.&amp;nbsp; When the user clicks 'Done' I call 'editorWidget.destroy()' and remove the DOM nodes.&amp;nbsp; When the editor is reactivated I recreate the nodes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, in my console, I get an error message - "Tried to register widget with id==editorDiv but that id is already registered".&amp;nbsp; I thought calling destroy() prevents that from happening?&amp;nbsp; The editor seems to work despite the error, but I don't want this error to display to users.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts on this?&amp;nbsp; Thanks, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Apr 2013 13:57:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510322#M47493</guid>
      <dc:creator>JamesTrier</dc:creator>
      <dc:date>2013-04-26T13:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510323#M47494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jim,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was able to reproduce the same error message.&amp;nbsp; Calling destroy() should prevent this.&amp;nbsp; After calling the destroy method, I checked the dijit.registry and the editorDiv widget was not there.&amp;nbsp; I'm not sure where else this could be stored.&amp;nbsp; This may be a bug.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm curious, when you enable editing do you have to execute your menu selection twice when you start an edit session for the first time?&amp;nbsp; When I start my edit session for the first time, I have to click on the 'Start Editing' button twice.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Apr 2013 19:16:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510323#M47494</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-04-29T19:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510324#M47495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function startEditing(){
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayers(editLayers);
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.connect(map, "onLayersAddResult", initEditing);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should be: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function startEditing(){
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.connect(map, "onLayersAddResult", initEditing);
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayers(editLayers);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This way, you're making the callback connection *before* adding the layers, instead of after. This should prevent you from having to click the 'start editing' button twice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve G.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:21:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510324#M47495</guid>
      <dc:creator>StevenGriffith</dc:creator>
      <dc:date>2021-12-11T22:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510325#M47496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, Steven!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Apr 2013 09:45:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510325#M47496</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2013-04-30T09:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot start editing with button</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510326#M47497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Jim,&lt;BR /&gt;&lt;BR /&gt;I was able to reproduce the same error message.&amp;nbsp; Calling destroy() should prevent this.&amp;nbsp; After calling the destroy method, I checked the dijit.registry and the editorDiv widget was not there.&amp;nbsp; I'm not sure where else this could be stored.&amp;nbsp; This may be a bug.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;I'm curious, when you enable editing do you have to execute your menu selection twice when you start an edit session for the first time?&amp;nbsp; When I start my edit session for the first time, I have to click on the 'Start Editing' button twice.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steven beat me to it (by some time, I need to check the forum more often!).&amp;nbsp; Since my code has the dojo.connect call before adding the layer, I did not see the behavior you mentioned.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;About calling destroy() on the widget, I found the issue.&amp;nbsp; Destroy() doesn't do enough - according to the Dojo documentation, destroy() doesn't remove a widget's descendants.&amp;nbsp; So the error crops up because parts of the widget are never destroyed.&amp;nbsp; I changed the destroy() call to destroyRecursive(false) and it solved the problem.&amp;nbsp; Now, each time the 'Edit' button is activated, it creates a 'new' editor, so there's no more conflicts. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From the Dojo documentation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;This is the generic "destructor" function that all widget users should call to cleanly discard with a widget. Once a widget is destroyed, it is removed from the manager object.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;source: &lt;/SPAN&gt;&lt;A href="http://dojotoolkit.org/api/1.7/dijit/_Widget/destroyRecursive"&gt;http://dojotoolkit.org/api/1.7/dijit/_Widget/destroyRecursive&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps Jake!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Apr 2013 14:27:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-start-editing-with-button/m-p/510326#M47497</guid>
      <dc:creator>JamesTrier</dc:creator>
      <dc:date>2013-04-30T14:27:59Z</dc:date>
    </item>
  </channel>
</rss>

