[记录]ns_error_unexpected firefox tinymce

参考:

  1. Form not saving, NS_ERROR_UNEXPECTED 
  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

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();之前执行:

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

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

1 <textarea id="f_desc_news" style=" 300px; height: 150px; display: none;" name="f_desc_news"></textarea>
 1 $(document).ready(function() {
 2 
 3     if($("#f_desc_news").length > 0){
 4         //tinymce.execCommand('mceAddEditor',true,'#f_desc_news');
 5         initTinymce();
 6     }else{
 7             //tinymce.execCommand('mceRemoveEditor',true,'#f_desc_news');
 8             removeTextArea()
 9     }
10 });

目前可行。

原文地址:https://www.cnblogs.com/fsong/p/5279700.html