uncaught exception: [CKEDITOR.editor] The instance "Textarea_EditDetail" already exists.

摘要:uncaught exception: [CKEDITOR.editor] The instance "Textarea_EditDetail" already exists.

 
uncaught exception: [CKEDITOR.editor] The instance "Textarea_EditDetail" already exists.
 
在使用 CKEditor 結合 CKFinder 時,會使用下面的語法整合
var editor = CKEDITOR.replace('Textarea_EditDetail'); 
CKFinder.setupCKEditor(editor, '../ckfinder/');
 
而因為特殊情況下,Textarea_EditDetail 的物件會先被清除
然後動作執行完後才又重新產生,這時候 CKditor 跟 CKFinder 就會壞掉
如果再重新執行整合的語法,就會出現上面的錯誤訊息
所以必須先利用下面的語法把之前建立的 CKEDITOR.editor 移除,在重建
var instance = CKEDITOR.instances['Textarea_EditDetail'];
if (instance) { CKEDITOR.remove(instance); }
然後再重新整合
var editor = CKEDITOR.replace('Textarea_EditDetail'); 
CKFinder.setupCKEditor(editor, '../ckfinder/');
就正常了~