LayUI弹窗确定后获取子页面的值(如获取UEditor富文本的内容,或input标签内容)
子窗体JS代码
<script src="~/lib/ueditor-1.4.3.3/ueditor.config.js"></script>
<script src="~/lib/ueditor-1.4.3.3/ueditor.all.js"></script>
<script>
var ue = UE.getEditor('container', {
initialFrameHeight: 300,
initialFrameWidth: 900
});
var callbackdata = function () {
var editorHtml = ue.getContent();//获取富文本内容
return editorHtml;
}
</script>
父窗体JS代码
var body;
layer.open({
title: '添加用户信息',
type: 2,
shade: false,
maxmin: true,
shade: 0.5,
btn: ['确认', '取消'],
area: ['500px', '400px'],
content: 'ArticleEdit',
zIndex: layer.zIndex,
success: function (layero, index) {
body = layui.layer.getChildFrame('body', index);//获取子窗体 body内容
},
yes: function (index, layero) {
var vvv = $(layero).find("iframe")[0].contentWindow.callbackdata();//这里是调用子页面的方法,并且 方法返回的内容
console.log(vvv);
var userName = body.contents().find("#userName").val();//假如子窗体有一个ID为userName的input 这里就是获取这个input的内容
layer.closeAll();
},
btn2: function () {
//alert("222"); 取消时触发
},
end: function () {
//关闭窗体时 触发
}
});
标签:body,UEditor,function,LayUI,获取,窗体,var,input
From: https://www.cnblogs.com/HeroZhang/p/18136013