AnsweredAssumed Answered

Attaching Delete Functionality to a Button

Question asked by ipeebles on Oct 14, 2013
Latest reply on Oct 14, 2013 by zj_zou
I have been trying to attach delete functionality to a button, but have had trouble getting it to work properly.  Here is my workflow:

1. User clicks on button to activate tool (an alert comes up that says tool activated).
2. The user points at a feature to delete feature.
3. The edits are applied and an alert comes up that says feature deleted.
3. The tool is then disconnected.

The user will have to click the button again, to reactivate the tool.  So far, I have been unable to get this to work.  Below are some code blocks.  Can somebody give me an idea on how I can get this to work?

var mapOnClick_Delete_connect; // Delete Button



function init() {   dojo.connect(map, "onClick", activateDelete); }


function activateDelete() {   mapOnClick_Delete_connect = dojo.connect(map, "onClick", deleteFeature);   alert("Delete feature tool activated."); }  function deleteFeature(results) {  var layers = dojo.map(evt, function (result) {  return result.layer;     });       // DELETE FEATURE USING ONCLICK     dojo.forEach(layers, function (deleteFeatureslLayer) {   dojo.connect(deleteFeatureslLayer, "onClick", function (evt) {         dojo.stopEvent(evt);          // DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE)         if (dijit.byId("DeleteFeature").checked) {             deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () {               operation = new esri.dijit.editing.Delete({                     featureLayer: deleteFeatureslLayer,                     deletedGraphics: [evt.graphic]      });      // ALERT WHEN FEATURE IS DELETED      alert("Feature deleted.")     });    }   });  }); }


I have having issues with this line of code:

if (dijit.byId("DeleteFeature").checked) {.  I no longer have a check box, just a button.

Outcomes