jquery、layer 实现弹出层的打开、关闭

父页面 js:

//$that为要绑定事件的jquery变量
$that.on('click', function () {
                                    layer.open({
                                        title: '医生认证审核',
                                        type: 2,
                                        content: '<%=staticPath%>/doctor/toDoctorReview/'+id,
                                        area: ['800px', '500px'],
                                        shadeClose: true,
                                        btn:['关闭'],
                                        success:function (data) {
                                            $.ajax({
                                               url:'<%=staticPath%>/doctor/changeLockStateReview',
                                               type:'post',
                                               data:JSON.stringify({
                                                   id:id,
                                                   isLock:1,
                                                   state:4
                                               }),
                                                dataType:'json',
                                                contentType:'application/json',
                                                success:function (result) {
                                                    if(result.code==200)
                                                        layer.msg("状态更新成功");
                                                    else
                                                        layer.msg("状态更新失败");
                                                },
                                                error:function (result) {
                                                    layer.msg("状态更新失败");
                                                }
                                            });
                                        },//关闭弹层时会调刷新本页面
                                        end:function (index) {
                                            location.reload(true);
                                        }

                                    });
                                    });

弹出层:

$('#agree').on('click',function () {
        $.ajax({
            url:'<%=contextPath%>/doctor/agreeApply/'+$("#userId").val(),
            type:'get',
            dataType:'json',
//            contentType:'application/json',

            success:function (data) {
                if (data.code=='200'){

                    layer.msg("审核成功");
                    //关闭动作的关键代码
                    //假设这是iframe页
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭

                }
                else
                    layer.msg("审核失败");
            },
            error:function (data) {
                layer.msg("审核失败");
            }
        });
    });

在 layer文档http://www.layui.com/doc/modules/layer.html 也能找到

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

每天进步一点_点

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值