layui自带layedit编辑器 使用除坑
HTML
部分:
<form>
<textarea id="content_edit" name="content" style="display:none"></textarea>
</form>
JS
部分:
<script>
layui.use(['form', 'layedit'], function () {
var $ = layui.jquery;
var form = layui.form;
var layedit = layui.layedit;
var content = layedit.build('content_edit'); //建立编辑器
/* 监听表单提交 */
form.on('submit(formSmsSubmit)', function (data) {
data.field.content = layedit.getContent(content);
$.ajax({
url: "{:url('xxx')}",
type:"POST",
data: data.field,
dataType:'json',
success: function (res) {
if (res.code === 200) {
layer.msg(res.msg, {icon: 1});
} else {
layer.msg(res.msg, {icon: 2});
}
},
error:function(){
layer.msg('提交失败', {icon: 2});
},
});
return false;
});
</script>