2017-01-30 4 views

ответ

2

Для выполнения отмены функции: editor.undoManager.undo();

+0

спасибо .. это работает прекрасно –

1

Тип Этот код

function updateButtons(history) { 
 
\t $('#undo').attr('disabled',!history.canUndo()); 
 
} 
 
function setEditorContents(contents) {$('#editor').val(contents);} 
 
$(function(){ 
 
\t var history = new SimpleUndo({ 
 
\t \t maxLength: 200, 
 
\t \t provider: function(done) { 
 
\t \t \t done($('#editor').val()); 
 
\t \t }, 
 
\t \t onUpdate: function() { 
 
\t \t \t //onUpdate is called in constructor, making history undefined 
 
\t \t \t if (!history) return; 
 
\t \t \t 
 
\t \t \t updateButtons(history); 
 
\t \t } 
 
\t }); 
 
\t $('#undo').click(function() { 
 
\t \t history.undo(setEditorContents); 
 
\t }); 
 
\t $('#editor').keypress(function() { 
 
\t \t history.save(); 
 
\t }); 
 
\t updateButtons(history); 
 
    });