• KindEditor 销毁与自动高度冲突解决


    前提准备情况:

    KindEditor(KE)  +  easyUI 

    1、通过 EasyUI.Window 打开一个窗口,窗口中包含一个 KE编辑器;在次打开WIndow 的时候 KE会出现编辑器里面的内容不变化,所以每次关闭窗口的时候销毁一次KE,销毁方法:KindEditor.remove('textarea[name="Contents"]');

    //编辑窗口
    $("#UIWindow").window({
    onBeforeClose: function () {    //当窗口关闭前
    KindEditor.remove('textarea[name="Contents"]');
    }
    });

    2、创建 KE编辑器,我这使用了一个动态方式创建和设置KE的值:

    //加载KindEditor 编辑器

    function loadEditor(id, Contents) {
    $("#" + id).val(Contents);
           editor = KindEditor.create('textarea[name="' + id + '"]', {
           allowFileManager: true,
            '98%',
           autoHeightMode: true,   //开启自动高度模式
           afterCreate: function () {
                 this.loadPlugin('autoheight')  //创建时设置编辑器高度为自动
           }
    });

    3、第一次操作一切正常,当第二次打开Window 的时候用火狐会提示以下内容:  

    4、经测试如去掉   autoHeightMode: true,   //开启自动高度模式 ,一切正常但失去了自动高度的效果不爽啊;

    解决办法:

    1、将创建 KE 的自动设置高度去掉,然后在创建完后一句代码增加另一个种设置编辑器高度的代码如下面红色字体;

      // autoHeightMode: true,
      // afterCreate: function () {
      // this.loadPlugin('autoheight')
      // },
    newlineTag: 'p'
    });
    var autoheight = editor.edit.doc.body.scrollHeight;
    editor.edit.setHeight(autoheight);

  • 相关阅读:
    angularjs MVC、模块化、依赖注入详解
    SpringBoot2.0整合Redission
    SpringBoot2.0整合SpringSecurity实现自定义表单登录
    SpringBoot2.0整合SpringSecurity实现WEB JWT认证
    基于Redis实现消息队列的几种方式
    函数初识
    noip200204过河卒
    邮票问题
    noip200205均分纸牌
    废品回收
  • 原文地址:https://www.cnblogs.com/intotf/p/4511911.html
Copyright © 2020-2023  润新知