2014-09-25 313 views
1

我使用Ace Editor在文本編輯器中加載Html內容,其中用戶編輯並保存他自己的內容。所以用戶可以退出並打開一個新的HTML。什麼是清除舊內容並加載新內容的程序。Ace Editor加載新內容動態清除舊內容

感謝您的幫助提前

回答

4

如果你想完全拋棄舊的內容,並明確撤消歷史使用

editor.session.setValue(text) 

如果你想保留舊的內容後恢復它,例如對於標籤,請使用

newSession = ace.createEditSession(text, mode/*optional*/) 
var oldSession = editor.session 
editor.setSession(newSession) 
// to restore old state call editor.setSession(oldSession)