2015-09-14 161 views
0

我在我的程序中使用tinymce作为文本编辑器,因此在添加表单中的数据并尝试使用AJAX保存之后,所有字段均正常保存,除了使用tinymce的textarea编辑,这里是我的代码,我的问题是(内容)的textarea:在AJAX中使用Tinymce编辑器

<script type="text/javascript"> 
tinymce.init({ 
selector: "textarea#content", 
theme: "modern", 
plugins: [ 
    "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker", 
    "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking", 
    "save table contextmenu directionality emoticons template paste textcolor" 
], 
content_css: "css/content.css", 
toolbar: "link image | fontselect fontsizeselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | print preview media fullpage | forecolor backcolor emoticons" 
}); 
    </script> 

<script type="text/javascript"> 
$(document).ready(function(){ 


$('#submit').click(function(){ 
$('#result').fadeOut("fast"); 
$('#wait').fadeIn("slow").delay(1000); 
    var title = $("input#title").val(); 
    var content = $("textarea#content").val(); 
    var student_year = $("select#student_year").val(); 
    var student_group = $("select#student_group").val(); 

    var direction = $("input#direction").val(); 

    var dataAll = { title:title, 
    content:content, 
    student_year:student_year, 
    student_group:student_group 
     } 
    $.ajax({ 
    url: direction, 
    type : "POST", 
    data : dataAll, 
    dataType :"html", 
    success : function(msg){ 
     $('#wait').fadeOut("fast"); 
     $('#result').fadeIn("slow"); 
     $('#result').html(msg) 

    } 

    }); 

}); 

}); 
</script> 

回答

1

请尝试加入这一行以下$('#submit').click(function(){

tinymce.triggerSave(); 
+0

感谢,现在的工作:“) –