2017-01-30 232 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); 
 
    });

相关问题