views:

89

answers:

3

Hi everybody,

I have seen more and more of the websites that offers a undo option after pressing a delete button. How is the logic done behind the button?

Is the item deleted by javascript and "dissapears" from the users screen and a scheduled delete added, that gives the user time to undo it or how does it work?

What are the other options to offer the users an undo feature?

+8  A: 

That really depends on the application's structure.

One common way is to not delete a record/an item, but mark it as deleted internally (using a boolean column), excluding it from all queries and lists.

If you have a node structure, you may want to move an item into a "recycle bin" node from where it can be restored to its original location.

In both variations, deleted items would be cleaned out from time to time - either based on time (delete after 3 weeks) or volume (keep max. 50 deleted items, then start deleting the oldest ones.)

Pekka
Hi Pekka, thanks a lot for your answer! Simple and easy solution! Great stuff
Industrial
+2  A: 

In HTML5 there will be a Undo implementation!

But nevertheless as Pekka said, your application must track what is done to "undo" it. One technical solution is, to save revisions of a document or of data. So when a user wants to undo something, just the previous revision is loaded.

powtac
+3  A: 

I would agree with Pekka, but additionally suggest that you make the column in question a datetime field, as opposed to boolean (call it "deleted on" or something).

This would easily enable the "delete after n weeks" functionality, as well as let you actually "undo" rather than simply "undelete".

Simon Scarfe
Yep! Good idea. We just implemented that. Thanks a lot!
Industrial