LayUI使用弹窗重载父级数据表格的两种方法

参考LayUI官方文档,在子窗口中重载父级数据表格找到以下两种方法:

1、子窗口中重载:在子窗口中直接调用父级talbe的reload方法。

        $("body").on("click", "#Test", function () {
            //刷新父级数据表格
            parent.layui.table.reload("demo");
            //关闭弹层
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭   
        });

2、父窗口中重载:通过Layer弹窗的End事件回调触发:

                        perContent = layer.open({
                            type: 2,
                            title: '添加讲师',
                            shadeClose: true,
                            shade: 0.8,
                            maxmin: true,
                            area: ['80%', '90%'],
                            content: '@Url.Action("Create", new { source = "index" })', //iframe的url
                            //通过end回调
                            end: function(){
                                table.reload('demo');
                            }
                        });
                        //以下代码可以弹窗直接全屏
                        layer.full(perContent);

猜你喜欢

转载自www.cnblogs.com/superfeeling/p/10929982.html
今日推荐