1. 程式人生 > >Layui父頁面向子頁面傳參

Layui父頁面向子頁面傳參

ble 獲取 子窗體 iframe title .html scree function 全局

廢話不多說!直接上代碼!

父窗體js

$(‘.mytable‘).on(‘click‘, ‘.editRow‘, function () {
        var table = $(‘#table_id_example‘).DataTable();
        var rowData = table.rows({selected: true}).data()[0];
        if (rowData) {
            layer.open({
                title: this.text,
                type: 2,
                skin: ‘layui-layer-rim‘, //加上邊框
                area: [window.screen.width / 2 + ‘px‘, window.screen.height / 2 + ‘px‘], //寬高
                maxmin: true, //開啟最大化最小化按鈕
                content: "taskDetail.html",
                success: function (layero, index) {
                    // 獲取子頁面的iframe
                    var iframe = window[‘layui-layer-iframe‘ + index];
                    // 向子頁面的全局函數child傳參
                    iframe.child(rowData);
                }
            })
        } else {
            alert("先選擇行")
        }
    })

子窗體


<script>
    function child(d) {
      alert(d)
    //在這裏你可以寫你的jquery $(function(){ })   等等操作


    }
</script>

Layui父頁面向子頁面傳參