Layui弹出层 加载 做编辑页面「建议收藏」

Layui弹出层 加载 做编辑页面「建议收藏」先上效果图基本准备,引入layui的layui.css,layui.js文件<linkrel="stylesheet"href="../../../Publics/others/layui/css/layui.css"media="all"><scriptsrc="../../../Publics/others/layui/layui.js">&a

大家好,又见面了,我是你们的朋友全栈君。

layui是一款优秀的模块化前端框架。利用layui弹出层做编辑页面

先上效果图

Layui弹出层 加载 做编辑页面「建议收藏」

基本准备,引入layui的layui.css,layui.js文件

    <link rel="stylesheet" href="../../../Publics/others/layui/css/layui.css" media="all">
    <script src="../../../Publics/others/layui/layui.js"></script>

Js方法

/**
 * 页面内弹出编辑窗口 //需要引入 layui.js layui.css文件
 * @param {} title 标题 不显示为false
 * @param {} area 大小 ["400px","500px"] 或者 "400px"--->只设置宽度
 * @param {} path 弹出页面路径
 * @param {} sucFunName 执行保存操作后再弹出页面中的保存方法名称
 * @param {} callBack 执行保存操作之后的其他操作
 * @returns {} 
 */
function openDetial(title, area, path, sucFunName, callBack) {
    layer.open({
        type: 2,
        title: title, //不显示标题栏
        closeBtn: 2,
        area: area,
        shade: 0.8,
        id: (new Date()).valueOf(), //设定一个id,防止重复弹出 时间戳1280977330748
        btn: ['保存', '取消'],
        btnAlign: 'r',
        moveType: 1, //拖拽模式,0或者1
        content: path,
        yes: function (index, layero) {
            var btn = layero.find('.layui-layer-btn').find('.layui-layer-btn0');
            alert("-----");
            try {
                var _ifr = btn[0].parentNode.parentNode.getElementsByClassName("layui-layer-content")[0].children[0].contentWindow ||
                     btn[0].parentNode.parentNode.getElementsByClassName("layui-layer-content")[0].children[0].children[0].contentWindow;
                var func = new Function('_ifr', "return _ifr." + sucFunName + "();");
                var flg = func(_ifr);
                if (flg == false) {
                    return false;
                } else {
                    if (callBack != null) callBack();
                    window.location.reload();
                }
            } catch (ex) {

            }
        },
        btn2: function (index, layero) {
        }
    });
}
//

以下是测试页面 测试页面中具备保存方法ApplicationSave() 

<!--// ========================================================================
// Author              :    Jp
// Email               :    1427953302@qq.com/dongmingzhixiu@outlook.com
// Create Time         :    2018-4-22 15:53:38
// Update Time         :    2018-4-22 15:53:43
// =========================================================================
// CLR Version         :    4.0.30319.42000
// Class Version       :    v1.0.0.0
// Class Description   :    编辑页面
// Computer Name       :    Jp
// =========================================================================
// Copyright ©JiPanwu 2017 . All rights reserved.
// ==========================================================================
-->
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width =device-width, initial-scale=1"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="Content-Language" content="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>JpAutoFramework</title>
    <meta content="victor" name="author"/>
     <script type="text/javascript">
        function ApplicationSave() {
            //具体保存操作
            //需要返回值,保存成功,返回true,保存失败返回false

        }
    </script>
    
</head >

<body οnlοad="load()" style="margin: auto">
<form>
    <table id="data" class="editorTable" style="margin: auto; margin-top: 50px; width: 80%;">
        <tr style="display: none;">
            <th> 编号 </th>
            <td> <input type="text" readonly="readonly" id="ID" /></td>
        </tr>
        <tr>
            <th> 项目名称 </th>
            <td> <input type="text" id="Names"  /></td>
        </tr>
        <tr>
            <th> 金额 </th>
            <td> <input type="text" id="PRICE" /></td>
        </tr>
        <tr>
            <th> 账目类型 </th>
            <td>
                <select type="text" id="ISOUT">
                    <option value="0">支出</option>
                    <option value="1">收入</option>
                    <option value="2">信用卡消费</option>
                    <option value="3">信用卡还款</option>
                </select>
            </td>
        </tr>
        <tr>
            <th> 日期 </th>
            <td> <input type="text" id="Dates" /></td>
        </tr>
        <tr>
            <th> 描述 </th>
            <td>
                <textarea rows="10" cols="38" id="Remark"></textarea>
            </td>
        </tr>
    </table>
</form>
</body >
</html >

调用 如下参数中的ApplicationSave和编辑页面的方法名一致

openDetial("列表维护", ['600px', '550px'], "./editor.html", "ApplicationSave", function() {alert("执行完了");});

有兴趣的小伙伴,可以试试


            //具体保存操作
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/140974.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • rapidjson指针[通俗易懂]

    rapidjson指针[通俗易懂]博客搬家,原地址:https://langzi989.github.io/2017/05/27/rapidjson指针/本系列文章以例子的方式进行呈现。#include”rapidjson/document.h”#include”rapidjson/pointer.h”#include<iostream>usingnamespacerapidjson;/…

    2022年10月27日
  • 浅谈时间轮算法[通俗易懂]

    浅谈时间轮算法[通俗易懂]时间轮在计算机世界中,只有待解决的问题变得大规模后,算法的价值才能够最大化的体现。时间轮算法可以将插入和删除操作的时间复杂度都降为O(1),在大规模问题下还能够达到非常好的运行效果。如果我们要实现一个定时任务该如何实现呢?最简单的方式就是使用一个任务队列来完成定时任务。具体实现细节下面详细展开。

    2022年9月27日
  • python操作ES数据库「建议收藏」

    python操作ES数据库「建议收藏」文章目录1、ES数据库和关系型数据库对比2、连接ES数据库3、插入数据4、查询数据1、ES数据库和关系型数据库对比一个ES集群可以包含多个索引(数据库),每个索引又包含了很多类型(表),类型中包含了很多文档(行),每个文档使用JSON格式存储数据,包含了很多字段(列)关系型数据库数据库表行列ES索引类型文档字段2、连接ES数据库fromelasticsearchimportElasticsearches=Elasticsearch([{“ho

    2022年6月1日
  • idea2021.8.2激活码(JetBrains全家桶)

    (idea2021.8.2激活码)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~BCEBXQ3A4G-eyJsaWNlbnNlSWQiOi…

    2022年3月22日
  • 关于网站备案相关流程的通知_网站备案需要什么资料

    关于网站备案相关流程的通知_网站备案需要什么资料最近遇到个头疼的事,关于网站备案。目前有个网站W,备案在A,但是服务器不在A,在B(用的是电信的接入ip),就在前几天收到一封来自A的邮件大致意思如下:经A扫描,发现网站W的服务器不在A,A要取消我们网站的接入,让我们处理这个问题。由于自己对这块东西本身就不熟悉,所以走了很多弯路(原因是多方面的,具体就不说了,不是重点),不过好在最终找到解决方案:在电信新增接入(10000号找个电

    2022年10月28日
  • plsql截取字符串_oracle截取字符串长度

    plsql截取字符串_oracle截取字符串长度oracle截取字符(substr),检索字符位置(instr)casewhenthenelseend语句使用收藏常用函数:substr和instr1.SUBSTR(string,start_position,[length])求子字符串,返回字符串解释:string元字符串start_position开始位置(从0开始)length可选项,子字符串的个数Fore…

    2022年11月1日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号