Layui父頁面向子頁面傳參


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

父窗體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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM