layui 使用富文本编辑器 添加内容为空解决办法
//百度富文本编辑器
var editor = UE.getEditor(‘LAY_editor2’, {
initialFrameHeight:450,
autoHeight: false,
autoHeightEnabled:false,
autoFloatEnabled:false
});
layui.use('form', function() {
var form = layui.form,layer = layui.layer,layedit = layui.layedit;
//数据异步提交未同步的原因,使用layedit.sync(index) 解决
form.on('submit(component-form-element)', function (data) {
$('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
// console.log(editor.body.innerHTML);return;
data.field.content = editor.body.innerHTML;
$.ajax({
url:"{:url('index')}",
type:'post',
dataType:'json',
data:data.field,
success:function(res){
if (res.code == 200) {
layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
wk.layer_close();
})
} else {
$(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
wk.error(res.msg);
return false;
}
}
})
});
});