本文主要是介绍layui中 子页面获取父页面的数据,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
父页面中
window.autosend = function (obj) {//获取对应行的数据,var datafather = obj.data;// console.log(data)layer.open({type: 2,maxmin: true,title: '选择发送时间',shade: 0.1,// area: screen(),area: ['600px', '400px'],content: 'autosend',success: function(layero, index){var body = layui.layer.getChildFrame('body', index);if(datafather){// 取到弹出层里的元素,并把编辑的内容放进去body.find(".id").val(datafather.id); //将选中的数据的id传到编辑页面的隐藏域,便于根据ID修改数据body.find(".email").val(datafather.email); //邮箱body.find(".attachment_path").val(datafather.attachment_path); body.find(".corporatename").val(datafather.corporatename); body.find(".serverip").val(datafather.serverip); body.find(".salesemail").val(datafather.salesemail); // 记得重新渲染表单form.render();}},end: function(){//刷新表格table.reload("dataTable")}})}
子页面中
<form class="layui-form" style="width: 100%;margin-top: 55px;" lay-filter="autosendTable" action=""><div class="layui-form-item"><div class="layui-inline"><label class="layui-form-label layui-required">年月日</label><div class="layui-input-inline layui-input-wrap"><!-- 使用隐藏域用于保存编辑项的ID值,便于提交修改 --><input type="hidden" class="id" name="id"><input type="hidden" class="email" name="email"><input type="hidden" class="attachment_path" name="attachment_path"><input type="hidden" class="salesemail" name="salesemail"><input type="hidden" class="corporatename" name="corporatename"><input type="hidden" class="serverip" name="serverip"><input type="text" name="corntime_yymmdd" lay-verify="required" id="corntime-yymmdd" autocomplete="off" placeholder="年月日(必填)"class="layui-input"></div></div>
测试是否获取到数据
<script>layui.use(['form', 'jquery'], function () {var form = layui.formvar $ = layui.jqueryvar layer = layui.layer; form.on('submit(autosend)', function (data) {var roleIds = ''$('input[type=checkbox]:checked').each(function () {roleIds += $(this).val() + ','})roleIds = roleIds.substr(0, roleIds.length - 1)data.field.roleIds = roleIdsconsole.log(data.field))}}
<\script>
这篇关于layui中 子页面获取父页面的数据的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!