Jquery javascript - How can I let users "undo" their changes?

I have a basic jquery application that allows the user to edit and manipulate some of the lists on a page. What I would like to do is click the "restore original list" button which the user can click to undo their changes.

What's the best way to do this? I thought to just copy the DOM from the list down and paste it into a hidden element somewhere else on the page. Is this the best way to do it?

I also noticed that jquery has a .data () function that I could use if I were to convert the data to an array and store it that way. What are the advantages and disadvantages?

Also, I am open to any suggestions people have if there is any method that I have not thought of.

Thanks for your help!

+2


a source to share


2 answers


Bill,

Phil Haack posted an article about a jQuery plugin he was working on named jquery.undoable. I didn't look at this much, but he wrote it to emulate the Netflix DVD queue.



His post: http://haacked.com/archive/2010/01/01/jquery-undoable-plugin.aspx

Github project: http://github.com/Haacked/jquery.undoable

+1


a source


Since your search is more like a "restore to original" rather than a step-by-step disabling, I'll go with the idea of ​​copying the dom / html elements, but instead of saving them as hidden, just store them in a variable. You may have to deal with post-insert event bindings, but it's pretty straightforward.



0


a source







All Articles