Home >Web Front-end >Layui Tutorial >How to close layui's open
Layui open closing method: first open and view the js part; then go to the modify article page; finally use the "layer.close(index)" method in the JS part of "articleUpdate.jsp" to close the specific layer. Can.
The operating environment of this tutorial: windows10 system, layui2.5.6. This article is applicable to all brands of computers.
Recommended: "layui tutorial"
layui-open closes its own window solution
1. The pop-up window here pops up a page, which pops up after passing through the background.
1.1. Implementation of the pop-up window
1.1 .1. The js part
function getArticleById(articleId){ var index = layer.open({ type: 2, title: '修改管理员', area: ['90%', '95%'], shade: 0.8, resize: false, fixed: false, move: false, shadeClose: false, content: '${ctxPath}/article/getArticleById?articleId='+articleId }); }
1.1.2. The background Java part
/** * 去到修改文章页面 * */ @RequestMapping("/getArticleById") public String getArticleById(@RequestParam("articleId") Integer articleId,Model model) { MrtArticle mrtArticle = mrtArticleService.getArticleById(articleId); model.addAttribute("mrtArticle",mrtArticle); return "article/articleUpdate"; }
The page will pop up when you get here
1.2 , close the pop-up window, use the following two lines of code in the JS part of articleUpdate.jsp to close itself
//当你在iframe页面关闭自身时 var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引 parent.layer.close(index); //再执行关闭 layer.alert('提交成功', { skin: 'layui-layer-molv' //样式类名 自定义样式 ,closeBtn: 1 // 是否显示关闭按钮 ,anim: 1 //动画类型 ,btn: ['确定'] //按钮 ,icon: 6 // icon ,yes:function(){ //当你在iframe页面关闭自身时 var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引 parent.layer.close(index); //再执行关闭 } });
layer.close(index) - Close a specific layer
There seems to be no need to introduce much about it. The only thing that makes you confused may be this index. In fact it's very easy to get.
If you are lazy, you don't want to get the index you just want to close. Then closeAll can really help you. If you don't point to a layer type, it will destroy all layers on the current page. Of course, if you only want to close a certain type of layer, then you can
The above is the detailed content of How to close layui's open. For more information, please follow other related articles on the PHP Chinese website!