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

“最难不过坚持”

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

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

6456321 2613 39
最新评论
https://jueru.net/
评 留言
:weixiao:
评 留言
:shuijiao: :weiqu: :zhenbang: :leng:
评 留言
:yiwen: :yiwen: :yiwen: :yiwen:
评 EasySass: could not generate CSS file. See Output panel for details.
这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
评 TP6模型事件-查询后onAfterRead不好用
文章标签更多
ThinkPHP (254)
Mysql (58)
DedeCms (33)
jQuery (67)
证件照 (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"]');
      }
    });
  });
})

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

相关推荐
Uncaught (in promise) 的解决方法,可能原因
其他 | 2022-06-25 1077567
Uncaught (in promise) 的解决方法,可能原因;仅仅只是一种参考原因 我是因为copy的项目直接修改的,结果一直报错 Uncaught (in promise),检查发现接口请求数据已经正常返回,后来经过排查发现是在拦截器里面别人的判断是response.data.status !== 1 就算请求失败,从而Promi...
钉钉怎样设置快捷键?钉钉系统设置在哪
其他 | 2019-03-20 21165
钉钉怎样设置快捷键? 1,打开电脑端钉钉面板,点击右上角自己的头像,下拉菜单中点击系统设置 2,进入系统设置面板,下拉滚动条,找到快捷键设置
评论:0条
评论加载中...
发表评论