


Detailed explanation of layer parent-child page interaction in layui framework
This article mainly introduces the method of layer parent-child page interaction in the layui framework. It analyzes the common techniques of layer parent-child page interaction in the form of examples and the operation method of layer popping up multiple iframes to find the parent page. Friends who need it can refer to it. I hope Can help everyone.
The example of this article describes the method of interaction between layer parent and child pages in the layui framework. Share it with everyone for your reference, the details are as follows:
layer is a web elastic layer component that has been popular in recent years. The official website address is: http://layer.layui.com/You can download the latest version from the official website.
When the layer pops up a new window (subpage) as an iframe layer, how to access the elements and functions of the parent page in the subpage.
1. Access parent page element value
var parentId=parent.$("#id").val();//访问父页面元素值
2. Access parent page method
var parentMethodValue=parent.getMethodValue();//访问父页面方法
3. How to close the pop-up child page window
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 parent.layer.close(index);//关闭弹出的子页面窗口
4 , How to refresh the parent page from the child page
parent.location.reload(); // 父页面刷新
Attachment: How to pop up multiple iframes in the layer to find the parent page
Parent page:
function aa(){ var index = parent.layer.getFrameIndex(window.name); var iframeName = 'layui-layer-iframe'+index; openDialog1('选择XXX', '${ctx}/*****,'800px', '500px',iframeName); } function openDialog1(title,url,width,height,target){ top.layer.open({ type: 2, area: [width, height], title: title, maxmin: true, //开启最大化最小化按钮 content: url , btn: ['确定', '关闭'], yes: function(index, layero){ var body = top.layer.getChildFrame('body', index); var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method(); var inputForm = body.find('#inputForm'); var top_iframe; if(target){ top_iframe = target;//如果指定了iframe,则在改frame中跳转 }else{ top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe } inputForm.attr("target",top_iframe);//表单提交成功后,从服务器返回的url在当前tab中展示 if(iframeWin.contentWindow.doSubmit(top_iframe) ){ top.layer.close(index);//关闭对话框。 top.window[iframeName].frames.location.reload();//刷新父亲 } }, cancel: function(index){ } }); } //子页面回调方法 function addRecord(name,chainName){ alert(name); }
subpage
function doSubmit(iframeName) { var sel=$("tbody tr td input.i-checks:checked"); var size = sel.size(); if(size==0){ top.layer.alert('请至少选择一条数据!', {icon: 0, title:'警告'}); return false; }else{ for(var i=0;i<size;i++){ top.window[iframeName].addRecord(sel[i].name,sel[i].value); } return true; } }
Related recommendations:
Detailed explanation of javascript parent-child page communication examples_javascript skills
Solution to the problem of value-passing in the tree shape in layui
The above is the detailed content of Detailed explanation of layer parent-child page interaction in layui framework. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

Layui login page jump setting steps: Add jump code: Add judgment in the login form submit button click event, and jump to the specified page through window.location.href after successful login. Modify the form configuration: add a hidden input field to the form element of lay-filter="login", with the name "redirect" and the value being the target page address.

layui provides a variety of methods for obtaining form data, including directly obtaining all field data of the form, obtaining the value of a single form element, using the formAPI.getVal() method to obtain the specified field value, serializing the form data and using it as an AJAX request parameter, and listening Form submission event gets data.

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of

"Methods to handle Laravel pages that cannot display CSS correctly, need specific code examples" When using the Laravel framework to develop web applications, sometimes you will encounter the problem that the page cannot display CSS styles correctly, which may cause the page to render abnormal styles. Affect user experience. This article will introduce some methods to deal with the failure of Laravel pages to display CSS correctly, and provide specific code examples to help developers solve this common problem. 1. Check the file path. First check the path of the CSS file.

Adaptive layout can be achieved by using the responsive layout function of the layui framework. The steps include: referencing the layui framework. Define an adaptive layout container and set the layui-container class. Use responsive breakpoints (xs/sm/md/lg) to hide elements under specific breakpoints. Specify element width using the grid system (layui-col-). Create spacing via offset (layui-offset-). Use responsive utilities (layui-invisible/show/block/inline) to control the visibility of elements and how they appear.

The difference between layui and Vue is mainly reflected in functions and concerns. Layui focuses on rapid development of UI elements and provides prefabricated components to simplify page construction; Vue is a full-stack framework that focuses on data binding, component development and state management, and is more suitable for building complex applications. Layui is easy to learn and suitable for quickly building pages; Vue has a steep learning curve but helps build scalable and easy-to-maintain applications. Depending on the project needs and developer skill level, the appropriate framework can be selected.

The method of using layui to transmit data is as follows: Use Ajax: Create the request object, set the request parameters (URL, method, data), and process the response. Use built-in methods: Simplify data transfer using built-in methods such as $.post, $.get, $.postJSON, or $.getJSON.
