Select to view content in your preferred language

Example of a confirm dialog prior to deleting a record while editing

2508
1
01-29-2016 06:55 AM
TracySchloss
Frequent Contributor

I am setting up an editor widget and I have included the delete button in the attributeinspector.   Rather than just deleting the record, I'd like to insert a dialog, that has a prompt like "Are you sure you want to delete?"  I assume I can use the result of the user's choice to determine whether or not to actually apply the edit.

I think I can use 'before-apply-edits' for this, but I can't wrap my head around how it all fits together. 

Does anyone has an example to share?

0 Kudos
1 Reply
TimWitt2
MVP Alum

Hey Tracy,

I know this is not an example but just looking at this example: Using the attribute inspector | ArcGIS API for JavaScript

The code for your pop-up would go here:

  attInspector.on("delete", function(evt) {
        evt.feature.getLayer().applyEdits(null, null, [evt.feature]);
        map.infoWindow.hide();
      });

Inside this function, I would create a dialogue div with 2 buttons yes and no. After the user clicks one of the two, put in an if statement that either deletes or doesn't depending on what the user clicked.

Once that is done don't forget to destroy the dialogue div, so you can re-create it once another delete button has been pressed.

Hope this helps!

Tim