LayUI弹窗确定后获取子页面的值(如获取UEditor富文本的内容,或input标签内容)

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 () {
//关闭窗体时 触发
}
});
posted @   冀未然  阅读(252)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示