Rej*_* CS 17 javascript jquery tinymce
我想清除tinymce内容并添加新内容.我尝试使用以下代码,但它附加到旧内容.如何清除tinymce中的现有内容.
tinymce.activeEditor.execCommand('mceCleanup');
tinymce.activeEditor.execCommand('mceInsertContent', false, result.content);
Run Code Online (Sandbox Code Playgroud)
Gop*_*esh 35
使用 :
tinyMCE.activeEditor.setContent('');
Run Code Online (Sandbox Code Playgroud)
将指定的内容设置为编辑器实例,这将在使用不同的清理规则选项设置之前清除内容.
参考:TinyMce
希望能帮助到你.
要清除现有内容,请尝试
tinyMCE.activeEditor.setContent("");
Run Code Online (Sandbox Code Playgroud)
然后使用相同的setContent()方法添加所需的内容:
tinyMCE.activeEditor.setContent(result.content);
Run Code Online (Sandbox Code Playgroud)
webkit 中有一个已知的错误,它会失去对文本区域的焦点,但解决方法是将其放在设置或初始化回调中:
tinyMCE.init({
mode : "textareas",
theme : "advanced",
setup : function(ed) {
if(tinymce.isWebKit) {
//workaround for Webkit to fix focus problems when setting contents to an empty string
ed.onSetContent.add(function() {
window.focus();
ed.focus();
});
}
}
Run Code Online (Sandbox Code Playgroud)
});
| 归档时间: |
|
| 查看次数: |
20170 次 |
| 最近记录: |