动态显示或隐藏kindeditor编辑器:异步加载
taotaoit 其他 2023-03-09 166 0
关于本站

“最难不过坚持”

本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作

有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339

3713855 2275 32
最新评论
<script>alert(11)</script>
评 留言
:kaixin: :haha:
评 phpExcel列数据自动换行的方法->getAlignment()->setWrapText(true);
666 :kaixin:
评 return和return false的区别
楼主很给力,请教了有一个问题,很细心给我解答,还帮我解决了问题。 :zhenbang: :zhenbang: :zhenbang:
评 留言
厉害 :zhenbang: :zhenbang: :zhenbang:
评 留言
文章标签更多
ThinkPHP (240)
Mysql (48)
DedeCms (33)
jQuery (58)
证件照 (1)
setInc (4)
setDec (4)
onclick (5)
打开边栏(ESC) 关闭边栏(ESC)

需求:页面上默认不显示编辑器,然后根据用户选择显示或隐藏编辑器。

参考:kindeditor异步加载

http://kindeditor.net/ke4/examples/dynamic-load.html

kindeditor所有演示示例

http://kindeditor.net/demo.php

html代码:

<textarea id="otherContent" name="otherContent" class="ipt form-control form-control-sm zht_w_lg_50" rows="2">内容</textarea>
            <input type="button" name="load" value="加载JS并创建编辑器" />
            <input type="button" name="remove" value="删除编辑器" />
js代码:

<script>
  $(function() {
    $('input[name=load]').click(function() {
      editor1 = KindEditor.create('textarea[name="otherContent"]', {
          height:'500px',
          uploadJson : ZHT.U('admin/base/editorUpload'),
          allowFileManager : false,
          allowImageUpload : true,
          themeType : "default",
          items:[     'source', 'undo', 'redo',  'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall',  'fullscreen',
                    'formatblock', 'fontname', 'fontsize',  'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image','multiimage','media','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink'
          ],
          afterBlur: function(){ this.sync(); }
        });
    });
    $('input[name=remove]').click(function() {
      KindEditor.remove('textarea[name="otherContent"]');
    });
  });
</script>
结合layui显示隐藏按钮

from clipboard

按钮:

<tr>
          <th>
            是否使用编辑器:
          </th>
          <td height='24' class="layui-form">
            <input type="checkbox" {if $rs.isEditor eq 1}checked{/if} id="isEditor" name="isEditor" value="1" class="ipt" lay-skin="switch" lay-filter="isEditor" lay-text="是|否">
          </td>
        </tr>
js代码:

//layui开关
$(function(){
  layui.use('form', function(){
    var form = layui.form;
    //监听提交
    form.on('switch(isEditor)', function(data){
      var id = $(this).attr("data-id");
      if(this.checked){
        editor1 = KindEditor.create('textarea[name="otherContent"]', {
          height:'500px',
          uploadJson : ZHT.U('admin/base/editorUpload'),
          allowFileManager : false,
          allowImageUpload : true,
          themeType : "default",
          items:[     'source', 'undo', 'redo',  'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall',  'fullscreen',
                    'formatblock', 'fontname', 'fontsize',  'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image','multiimage','media','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink'
          ],
          afterBlur: function(){ this.sync(); }
        });
      }else{
        KindEditor.remove('textarea[name="otherContent"]');
      }
    });
  });
})

版权声明:本站原创文章,允许自由转载。

相关推荐
钉钉怎样设置快捷键?钉钉系统设置在哪
其他 | 2019-03-20 18668
钉钉怎样设置快捷键? 1,打开电脑端钉钉面板,点击右上角自己的头像,下拉菜单中点击系统设置 2,进入系统设置面板,下拉滚动条,找到快捷键设置
virtualbox安装增强功能时点击没反应
其他 | 2017-06-24 11555
利用virtualbox虚拟机装了一个windows2003的系统,但是虚拟机到主机之间的双向复制粘贴不能用,所以就想到了virtualbox菜单里的“设备>安装增强功能”,但是点击没反应,经网上搜索解决: 进入“我的电脑”,在“cd驱动器”上点击右键选择“弹出”,然后就可以安装增强功能了,如图:
评论:0条
评论加载中...
发表评论