【LAYUI】Table页面向Iframe子页面传值

it2022-12-26  91

Table页面向Iframe子页面传值

Input赋值Radio赋值IMG赋值富文本XM-select赋值

/** * tool监听 */ table.on('tool(currentTableFilter)', function (obj) { var data = obj.data; console.log(data); if (obj.event === 'edit') { var index = layer.open({ title: '编辑店铺信息', type: 2, shade: 0.2, shadeClose: true, area: ['100%', '100%'], content: '/shop/edit?id=' + data.id, success: function (layero, index) { $(layero).addClass("scroll-wrapper"); let fbody=layer.getChildFrame('body',index); //获取操作对象 let fwindow=window[layero.find('iframe')[0]['name']]; fbody.find("input[name='shopId']").val(data.id); fbody.find("input[name='shopName']").val(data.shopname); fbody.find("input[name='address']").val(data.address); fbody.find("input[name='addressTag']").val(data.addresstag); fbody.find("input[name='stars']").val(data.stars); fbody.find("input[name='lessonScore']").val(data.lessonscore); fbody.find("input[name='teachScore']").val(data.teachscore); fbody.find("input[name='envScore']").val(data.envscore); fbody.find("input[name='openTime']").val(data.opentime); fbody.find("input[name='phoneNumber']").val(data.phonenumber); fwindow.layui.form.render(); //更新表单 } }); $(window).on("resize", function () { layer.full(index); }); return false; }else if (obj.event==='delete'){ console.log('delete') } });

Input赋值

fbody.find("input[name='openTime']").val(data.opentime); fbody.find("input[name='endTime']").val(timestampToTime(data.endtime));

Radio赋值

changeChildRadio(fbody.find("input[name='state']"), data.state); //改变子页iframe中的radio的选择状态 function changeChildRadio(input, value) { for (let i in input) { let val = input.eq(i).val(); if (val == value) { input.eq(i).prop("checked", "checked"); break; } } }

IMG赋值

fbody.find("#img").attr('src', data.titleimg);

富文本

fwindow.editor.txt.html(data.content); fwindow.layui.form.render();

XM-select赋值

let groupData = (data.groups).split(","); iframeWin.groupSelect.setValue(groupData) //子页面初始化的下拉框 var groupSelect = xmSelect.render({ el: document.querySelector("#group"), name: 'groups', layVerify: 'required', layVerType: 'msg', data:[...] })
最新回复(0)