Javascript 如何使用jquery在ajax操作后清空TINYMCE内容
我使用jQueryAjax函数在一些输入字段和文本区域中添加内容。只有textare使用TINYMCE 但是在ajax之后,TINYMCE中的文本不会刷新并保留 如何使用jquery清空TINYMCE中的内容 我当前的代码如下Javascript 如何使用jquery在ajax操作后清空TINYMCE内容,javascript,jquery,tinymce,Javascript,Jquery,Tinymce,我使用jQueryAjax函数在一些输入字段和文本区域中添加内容。只有textare使用TINYMCE 但是在ajax之后,TINYMCE中的文本不会刷新并保留 如何使用jquery清空TINYMCE中的内容 我当前的代码如下 //on submit event $("#specformentry").submit(function(event){ event.preventDefault(); if(checkForm()){ //
//on submit event
$("#specformentry").submit(function(event){
event.preventDefault();
if(checkForm()){
// var href = $(this).attr("href");
submitinput.attr({ disabled:true, value:"Sending..." });
//$("#send").blur();
//send the post to shoutbox.php
$.ajax({
type: "POST",
url: "../../Ajaxinsertspec",
data: $('#specformentry').serialize(),
complete: function(data){
update_entry();
specdesc.val('');
datecreated.val('');
detailstext.val('');
// this code is supposed to empty the INYMCE content, but it does not
//reactivate the send button
submitinput.attr({ disabled:false, value:"Enter Spec" });
}
});
}
else alert("Please fill all fields!");
//we prevent the refresh of the page after submitting the form
return false;
});
下面是HTML的一部分
<div id="enterlabel"><label for="spec_details">Click me to enter Spec Details</label></div>
<div style="display: block;" id="textarea">
<textarea style="display: none;" name="spec_details" cols="90" rows="12" id="detailstext"></textarea>
<span class="mceEditor defaultSkin" id="detailstext_parent">
<table style="width: 100px; height: 100px;" class="mceLayout" id="detailstext_tbl" cellpadding="0" cellspacing="0">
<tbody><tr class="mceFirst">
<td class="mceToolbar mceLeft mceFirst mceLast"><a href="#" accesskey="q" title="Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to...
...
单击我以输入等级库详细信息
您不需要jQuery来清空tinymce。按id获取tinymce实例,并使用将内容设置为'
(等于空)
//第一编辑的身份证
可在中找到该页的
tinymce.editors[0].id
试试下面的代码
if (typeof(tinyMCE) != 'undefined') {
$('#edit-comment').val(''); // Removes all paragraphs in the active editor
}
这对我很有用:
tinyMCE.activeEditor.setContent('');
尤其是当它是您页面中唯一的编辑器时。谢谢您解决了我的问题$(document).ready(函数(){var tinymce_editor_id='my_tinymce_id';tinymce.get(tinymce_editor_id).setContent('');});就够我的案子了,没有了!:)这对我有效,而投票最多的解决方案却无效。
tinyMCE.activeEditor.setContent('');