tags:

views:

190

answers:

3

Is there a library that can be used for implementing undo/redo functionality for DOM element manipulations in JavaScript?

I'm writing an prototype.js app (memonaut) that moves around DOM elements, enables editing and deletion of those elements. There are event-handlers and other objects associated with each element operated upon.

Not sure whether I need to roll my own implementation of the Command pattern for this. Surely, there must be something available? If not, suggestions and pointers would be a great help.

+5  A: 

Have a look at the jQuery plug-in "undoable".

aeby
is there anything you know about for Prototype?
sonofdelphi
I never used Prototype, sorry. I only know YUI, ExtJS and jQuery.
aeby
jquery can 'co-exist' with prototype, use the no conflict option http://api.jquery.com/jQuery.noConflict/ var $j = jQuery.noConflict(); // now use $j for jquery and continue to use $ for prototype
house9
+1  A: 

Prototype only offers shallow cloning of objects. So I believe you'll need to roll your own deep cloning method (this might help). Then as your user manipulates the DOM you can simply push the cloned versions onto a stack and pop them off the stack if the user chooses to undo.

Matt S
+1  A: 

hey,

i have seen undo-redo in GWT graphs API. You can check the following URL.

GWT is a library everyone uses today. It supports implement code in Java classes and then compiles it into JS.

Try finding around it, as we have implemented once thing like flow diagram web application which was supported undo/redo upto n levels..

hope this helps.

http://code.google.com/p/gwt-dnd/

Paarth