zoukankan      html  css  js  c++  java
  • 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);

  • 相关阅读:
    HDU Ignatius and the Princess III (母函数)
    HDU 1014 Uniform Generator
    HDU 1013 Digital Roots
    HDU u Calculate e
    HDU 1005 Number Sequence 找规律
    Vijos 送给圣诞夜的极光(bfs)
    HDU Sum Problem (一道神坑的水题)
    Vijos CoVH之再破难关(搜索+hash)
    VIjos 晴天小猪历险记之Number (搜索+链表hash)
    Vijos 有根树的同构问题【字符串---最小表示法】
  • 原文地址:https://www.cnblogs.com/intotf/p/4511911.html
Copyright © 2011-2022 走看看