layer中父子层的信息交互

父层:

//编辑页面
                    layer.open({
                        type: 2, //type为2,才会显示网页
                        title: '编辑店铺信息',
                        skin: 'layui-layer-rim', //加上边框
                        area: ['500px', '300px'], //宽高
                        content: '/edit_shop/?shop_id=' + data.shop_id + '&shop_name=' + data.shop_name + '&shop_url=' + data.shop_url, //子页面地址,会通过urls.py
                        shadeClose: true, //点击遮罩关闭层
                        btn: ['修改', '取消'],
                        yes: function (index, layero) {
                            //调用edit_shop页面的函数
                            var iframeWin = $("div.layui-layer-content > iframe")[0].contentWindow; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
                            iframeWin.form_submit(); //调用子页面的form_submit函数
                            layer.close(index);
                        },
                        no: function (index, layero) {
                            layer.close(index);
                        },
                        end: function (index) {
                            //这个要写在end中,如果卸载yes中,从这一次表不会更新,为什么?
                            table.reload('idTest')
                        }
                    });   
后端: Django 的views.py

def edit_shop(request):
    shop_id = request.GET.get('shop_id', None)
    shop_name = request.GET.get('shop_name', None)
    shop_url = request.GET.get('shop_url', None)
    # models.py中的类型不能覆盖构造函数
    # shop = Shop(shopId, shopName, shopUrl)

    # 如何利用传过来的参数呢,重新查岂不是不如只传id??????
    shop = Shop.objects.get(shopId=shop_id)

    logging.info('编辑店铺 shop_id=' + shop_id + ' shop_name=' + shop_name.encode('utf-8') + ' shop_url=' + shop_url)
    return render(request, 'edit_shop.html', {'shop': shop})

子层:edit_shop.html


{% csrf_token %}

查找的资料:

layer与iframe 间值的相互传递:http://www.cnblogs.com/xujian2016/p/7251710.html

layer通过父页面调用子页面的方法及属性:http://blog.csdn.net/qq_28550739/article/details/53389588

iframe父子兄弟之间调用传值(contentWindow && parent):http://www.cnblogs.com/duankaige/archive/2012/09/20/2695012.html


layer父子页面交互:http://blog.csdn.net/dragonpeng2008/article/details/52607005

你可能感兴趣的:(前端)