0

Possible Duplicate:
Undo/redo Plugin in jquery

I want to realize Undo/Redo system on my html tables: adding tr, deleting tr, cell editing.

Is there some JavaScript libraries to make that?

Community
  • 1
  • 1
Erik
  • 14,060
  • 49
  • 132
  • 218

1 Answers1

2

Well, there is a document.execCommand(command) function which can undo/redo native actions (like text typing etc..). But if the edits are custom, i.e. unknown to the native browser application. For ex: typing text in a textbox is not a custom action, the browser knows how to undo it. But adding a div on the click of a button is a custom action.

If its a custom action, you'll need to use an event queue or something which keeps track of the actions you perform. On undo, you can rollback the last item in the list (and mark it as 'undone'). On redo, you can process the next available action in your list thats marked as undone.

techfoobar
  • 65,616
  • 14
  • 114
  • 135