layer弹出层回调函数调用弹出层页面函数 您所在的位置:网站首页 layer弹出框出不来 layer弹出层回调函数调用弹出层页面函数

layer弹出层回调函数调用弹出层页面函数

2023-03-12 21:22| 来源: 网络整理| 查看: 265

1、项目中用到layer 弹出层,定义一个公用的窗口,问题来了窗口弹出来了,如何保存页面上的数据呢?疯狂百度之后,有了结果,赶紧记下。

2、自己定义的公共页面方法:

layuiWindow: function (options) {

var defaults = { title: '添加菜单', width: '100px', height: '100px', url: '', shade: 0.3, btn: ['确认', '关闭'], btnclass: ['btn btn-primary', 'btn btn-danger'], callBack:null };

var optiOns= $.extend(defaults,options);

alert(options.width

+"=+="+ options.height);

//页面层 layer.open({ type: 2, title: options.title, //skin: 'layui-layer-rim', //加上边框 area: [options.width, options.height], //宽高 content: options.url, btn: options.btn, //只是为了演示 yes: function(){ options.callBack(); }, btn2: function(){ layer.close(); } }); }

 3、父页面:

$.layuiWindow({ title: "菜单新增", url: "/SysMenu/Form?Id=" + id + "&Name=" + name, width: '400px', height: '300px', callBack: function () { //top.frames["Form"].submitForm(); //$(la).find("iframe")[0].contentWindow.submitForm(); window["layui-layer-iframe1"].submitForm(); //这里是重点,赶紧圈起来这里一定会用到。 } });

 4、子页面方法:

//保存数据 function submitForm() { var parentId = $("#parentId").val(); var childrenNode = $("#txtChildren").val(); var path = $("#txtPath").val(); $.ajax({ url: "/SysMenu/Insert", data: { parentId: parentId, name: childrenNode, menuPath: path }, dataType: "json", type: "post", success: function (req) { alert("req" + req); }, error: function (err) { alert("err"+err); }

}); }

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有