-7

I want to create an undo button for my web application using javascript. Can someone please help. Basically i got an web app which has got features such as Drawing, Image effect, and Drag and Drop. These functionality are performed on one canvas. All i need is an #Undo button so that if i do a mistake i can go one step backwards. I cant use Jquery. I am looking for a pure javascript to implement that function.

3

2 Answers 2

2

You haven't given much info, so I'll make assumptions.

  1. Assumption 1: all you user drawing interactions are recorded in an array.
    If this is true then simply clear the canvas and redraw the interactions from the array to interactionArray.length -1;

  2. Assumption 2: You're using multiple canvas.
    If this is true, hide/remove the last (most top) canvas element.

If you're not using either of these methods, maybe look into these methods. Or give us more information on the the method you're currently using.

Note: There are certainly not the only methods to including an "undo" feature!)

Sign up to request clarification or add additional context in comments.

1 Comment

what a great idea! I originally thought of reverse engineering every button but your idea makes so much more sense, thanks for sharing!
1

Depends on your web application, but shouldn't this do?

<button type="reset">Click Me!</button>

or in js:

<a href="javascript:document.Testform.reset()">Reset Form</a>

2 Comments

i got image effect and drawing inside the canvas so any movement isdone i got to move one step forward
Isn't that what your looking for? How to clear the canvas for redrawing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.