异步load()加载 ckeditor 编辑器

异步加载ckeditor 编辑器,注意事项:

第一.CKEDITOR 未定义:js未加载ckeditor.js 

解决方案:

1.将 js文件放在父页面

<script src="http://www.cnblogs.com/../Content/ckeditor/ckeditor.js" type="text/javascript"></script>
<script src="http://www.cnblogs.com/../Content/ckeditor/ckfinder/ckfinder.js" type="text/javascript"></script>

2. 首次请求 生成编辑器,再次加载时,需要销毁上次生成的编辑器,重新 生成新的 编辑器

 <textarea  id="Content" rows="6" cols="10"></textarea>
    <script type="text/javascript">

        jQuery(function ()
        {
             // 300 弹窗高调
             LoadCk(300);
           
        });

        function LoadCk(hh)
        {

            //加载CKeditor
            //判定 Content 是否存在
            var editor;
            if (!CKEDITOR.instances.Content) {
               
                var editor = CKEDITOR.replace('Content', { height: 300 });
                

            } else {
                
                addCkeditor("Content", hh);
            }

        }
      //新增CKEDITOR
        function addCkeditor(id, hh)
        {
            var editor2 = CKEDITOR.instances[id];
            //销毁编辑器 Content, 然后新增一个
            if (editor2) editor2.destroy(true);
            editor = CKEDITOR.replace(id, { height: hh });
            
        }
    </script>
View Code

参考:http://blog.sina.com.cn/s/blog_7795200201013cjt.html

第二:lang.contextmenu.options' 为空或不是对象

解决方案: 实质ckeditor js文件引用问题

1.对官方ckeditor.js 进行修改,导致某些配置勿删

2.ckeditor.js 路径是否正确

第三: ckeditor.js文件配置详情

参考 :http://blog.csdn.net/yangchaofeng1229/article/details/6723235

原文地址:https://www.cnblogs.com/lei2007/p/3080303.html