// 初始化富文本框
layui.use(['form','layedit'], function () {
var layedit = layui.layedit;
$("#demo").text(data.org_desc);
index = layedit.build('demo',{tool: ['strong', 'italic','underline','del','|','left','center','right','|','link','image','|','code']});
});
表单提交数据处理(layui编辑器空格符自动识别不了 需要进行转换)
form.on('submit(formDemo)', function (data) {
var str = $(data.form).serialize();
var arr = str.split("&");
var param = {};
var str1 = layedit.getContent(index);
str1 = str1.replace('nbsp; :',"/r/n");
$(arr).each(function (k,v) {
var arrstr = v.split("=");
param[arrstr[0]] = decodeURIComponent(arrstr[1],true);
});
param['org_desc'] = decodeURIComponent(str1,true);
param['id'] = user_data.org_id;
$.ajax({
url: req_url+"hospital_add",
type: "POST",
data: param,
dataType: "Json",
success: function (info) {
layer.msg(info.msg);
}
});
return false;
});