Layer.js a child window closes and passes data to the parent window method

Source: Internet
Author: User

It was late last night and I couldn't find a way. To the official website API to see for a long time, and searched the Internet for a long period always can not find the answer. Today I finally found a way.

Difficulty: Because both the Confirm and cancel buttons are called in the parent window of the JS generated button. You can only go back to the data and close the child window when the parent window is recalled. Not the Subwindow itself closes and the data is passed to the parent window. Many of the answers on the web are the way the subwindow closes itself and passes the data to the parent window.

"By sticking out my own code, I've probably implemented the process." Specific self-modification according to the circumstances "

My Code function is a child window to pass an array to the parent window, a specific complex data format (such as JSON, etc.) similar to

1. sub-window code

   var URLs;    function Geturls ()    {        return URLs;    }

The value of the variable is passed out in a method

2. The Code of the parent window

function Openwindow ()    {        Top.layer.open ({            ID: "Uploadpic",            title: "Image upload",            content: "/actor/ Uploadpic ", area            : [" 800px "," 580px "],            shade:0.3,            type:2,            fix:false,            btn: [' Confirm ', ' close '],            Btnclass: [' btn btn-primary ', ' btn Btn-danger '],            yes:function (index, Layero) {                var tem = $ (Layero). Find ("Ifra Me ") [0].contentwindow.geturls ();                Piccallback (TEM);                Parent.layer.close (index);            }, Cancel:function () {                return true;            }        });    

The method of the tone window takes the data and closes the child window

3.

The Piccallback method is the parent window's method, the parameter is the data which passes from the child window, the concrete method does not write,
That's probably the process.

Layer.js a child window closes and passes data to the parent window method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.