ITeye博客

uncaught exception: [CKEDITOR.editor] The instance “xxxx” already exists

fuanyu · 2011-10-28 11:55 · js · Web前端 · Markdown

主要防止加载同一个id,如下代码

<span>
                 <textarea cols="80" id="content2" name="content2" rows="10" >${email.content?default('')}</textarea>
					 <script type="text/javascript">
                      
                    //添加ckeditor编辑器;
                       var editor ;
                        if(!CKEDITOR.instances.content2){  //判定content2是否存在
                             editor= CKEDITOR.replace("content2");
                        }else{
                               addCkeditor("content2");
                        }
                         
                    function addCkeditor(id){
                        var editor2 = CKEDITOR.instances[id];
                        if(editor2) editor2.destroy(true);//销毁编辑器 content2,然后新增一个
                            editor = CKEDITOR.replace(id);
                    }
                     </script>
                  </span>
                 

 有一些代码参考:http://www.toobull.com/archives/177.html

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。