• 0
  • 0

富文本编辑器文档 - layui.layedit

2019-07-19 212 0 admin 所属分类:LAYUI

编辑器HTML代码

<div class="layui-form-item">
    <label class="layui-form-label">内容</label>
    <div class="layui-input-block" id="content">
        <textarea class="layui-textarea" id="LAY_textarea" style="display: none">{echo htmlspecialchars($good['content'])}</textarea>
    </div>
</div>

引入LAYUI layedit模块 初始化操作

layui.use('layedit', function() {
    var layedit = layui.layedit;
    //建立编辑器
    var edit = layedit.build('LAY_textarea', {
        height: 400,
        uploadImage: {
            type: 'POST',
            url: 'xxxxx'
        }
    });
});

请求提交携带编辑器数据

$('#submit').click(function() {
    layer.load(0);
    var index = layer.load(0);
    $.post("/admin/{$mod}/{$ac}.html?_={$_GET['_']}", $('#form').serialize() + '&content=' + encodeURIComponent(layedit.getContent(edid)), function(data) {
        if (data.status) {
            parent.layer.msg('执行成功');
            parent.layer.closeAll('iframe');
            parent.$("#search").trigger("click");
        } else {
            layer.msg(data.msg, {
                icon: 2,
                time: 1500
            });
        }
        layer.close(index);
    });
});



返回顶部