Ajax应用中CKEDITOR多实例问题的解决
今天在修改 OPENCART 的后台时。用Ajax把商品的增添编辑页面调用来。。第一次调入时,一切正常。噩梦从第二次开始。。原来是第一次点击链接,调用内容时,已经进行了一次CKEDITOR的实例化,第二次调入时必然会与第一次的冲突。。
修改:
CKEDITOR.replace('description<?php echo $language['language_id']; ?>', { filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>' });
之前加上
if(CKEDITOR.instances['description<?php echo $language['language_id']; ?>']) { CKEDITOR.remove(CKEDITOR.instances['description<?php echo $language['language_id']; ?>']); }
最后代码
<script type="text/javascript"> <?php foreach ($languages as $language) { ?> if(CKEDITOR.instances['description<?php echo $language['language_id']; ?>']) { CKEDITOR.remove(CKEDITOR.instances['description<?php echo $language['language_id']; ?>']); } CKEDITOR.replace('description<?php echo $language['language_id']; ?>', { filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>', filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>' }); <?php } ?> </script>
P.S. 参考 http://www.cnblogs.com/cocowool/archive/2010/09/04/1817989.html
相关推荐
heyboz 2020-10-21
lukezhong 2020-10-14
tangxiong0 2020-09-03
zhaowj00 2020-07-05
寻常白昼 2020-06-14
luvhl 2020-06-08
oXiaoChong 2020-06-03
chenlxhf 2020-05-06
是一道经常出现在前端面试时的问题。如果只是简单的了解new关键字是实例化构造函数获取对象,是万万不能够的。更深入的层级发生了什么呢?同时面试官想从这道题里面考察什么呢?下面胡哥为各位小伙伴一一来解密。
haohong 2020-04-08
JF0 2020-03-20
fanhuasijin 2020-03-01
横云断岭 2020-02-20
zhouyuqi 2020-01-20
kong000dao0 2020-01-11
年轻就要对味 2014-07-11
发条戏子 2019-12-27
王志龙 2019-12-26