[记录]ns_error_unexpected firefox tinymce

时间:2023-03-08 22:33:57

参考:

  1. Form not saving, NS_ERROR_UNEXPECTED [记录]ns_error_unexpected firefox tinymce
  2. Error: NS_ERROR_UNEXPECTED #794
  3. NS_ERROR_UNEXPECTED on Firefox when init again same id after Ajax reload #2671  link to:http://fiddle.tinymce.com/spfaab[记录]ns_error_unexpected firefox tinymce

Tinymce version: 4.0.18 (2014-02-27)

Jquery version:1.10.2

项目中,body是ajax加载进来的,即Form也是ajax load进来的。init和remove的方法我放到项目中header.php,

function initTinymce() {
//tinymce.remove();
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
}
function removeTextarea() {
tinymce.remove(); // <-- Remove all editors before removing the editors HTML
}

在Submit方法中,再提交$.post();之前执行:

 if($("#f_desc_news").length > 0){
tinymce.EditorManager.triggerSave();
// for (edId in tinyMCE.editors)
// tinyMCE.editors[edId].save();
}

在ajax load的页面body-edit.php中,代码是:

 <textarea id="f_desc_news" style="width: 300px; height: 150px; display: none;" name="f_desc_news"></textarea>
 $(document).ready(function() {

     if($("#f_desc_news").length > 0){
//tinymce.execCommand('mceAddEditor',true,'#f_desc_news');
initTinymce();
}else{
//tinymce.execCommand('mceRemoveEditor',true,'#f_desc_news');
removeTextArea()
}
});

目前可行。