我正在尝试动态更改tinymce编辑器的内容。即使这个步骤也不起作用。实际上我想将内容放在ajax成功上,但由于它不起作用我无法继续。
我收到类型错误tinemce.get() is null and tinymce.activeEditor is null 错误
<textarea style="height:700px" name="proposal" id="proposal" >
hi
</textarea>
<script>
$(document).ready(function () {
tinymce.init({
selector: "#proposal",
height: 250,
theme: "modern",
plugins: [
"autoresize advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor colorpicker textpattern imagetools codesample toc"
],
toolbar1: "undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media | forecolor backcolor emoticons | codesample",
image_advtab: true,
content_css: [
"https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css",
],
});
var content = "<p>Hello World </p>";
tinyMCE.get("proposal").setContent(content);//not working
tinyMCE.activeEditor.setContent(content);//not working
});
<script>
Run Code Online (Sandbox Code Playgroud)
在Tinymce 4中你可以尝试一下:
// Sets the HTML contents of the activeEditor editor
tinymce.activeEditor.setContent('<span>some</span> html');
// Sets the raw contents of the activeEditor editor
tinymce.activeEditor.setContent('<span>some</span> html', {format: 'raw'});
// Sets the content of a specific editor (my_editor in this example)
tinymce.get('my_editor').setContent(data);
// Sets the bbcode contents of the activeEditor editor if the bbcode plugin was added
tinymce.activeEditor.setContent('[b]some[/b] html', {format: 'bbcode'});
Run Code Online (Sandbox Code Playgroud)
通过Tinymce阅读更多内容
归档时间: |
|
查看次数: |
10290 次 |
最近记录: |