jqueryhtmleditorundo-redofroala

How to reset the states of (UNDO & REDO) button on froala editor


Hi i am using froala editor to save html for each stages ..

consider there are three stages.. A,B and C ..

Froala editor is only one

$('#txt_blog_editor').editable({
}); 

The div is same for all the three stages as stages can be created dynamically .. i have an issue here with the REDO and UNDO buttons..

Example

On click of Stage A and i type "This is stage A"

then i press stage B

The div is cleared and then i type "This is Stage B"

here when i press undo button the text changes to "This is Stage A". I want to clear redo undo history/cache/buffer and also CTRL + Z on click of the stages .

Is there any direct method in froala to destroy the history or reset the state of Redo & Undo buttons.


Solution

  • You would have to clear the undoStack.

    $(your_selector).data('fa.editable').undoStack = [];
    $(your_selector).data('fa.editable').undoIndex = [];
    $(your_selector).data('fa.editable').saveUndoStep();
    


    Or simpler:

    $(your_selector).editable('initUndoRedo');