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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 过分了,别人用来做桌面应用开发,这家伙却用来撩妹(4)–运动的火柴人

    过分了,别人用来做桌面应用开发,这家伙却用来撩妹(4)–运动的火柴人

    2022年2月21日
    39
  • 双系统ubuntu20.04安装教程_ubuntu20.04网络配置

    双系统ubuntu20.04安装教程_ubuntu20.04网络配置文章目录1.激活VMware1.2下载ubuntu20.04镜像2.安装虚拟机3.安装ubuntu20.043.1开启此虚拟机3.2安装ubuntu我的网站:https://pythoneers.cn1.激活VMware下载链接:https://www.vmware.com/cn/products/workstation-pro/workstation-pro-evaluation.html安装完成后,选择【帮助】,输入许可证密钥。1.2下载ubuntu20.04镜像htt.

    2022年10月4日
    2
  • SQL Server 2008还原数据库时出现“备份集中的数据库备份与现有的数据库不同”的解决方法

    SQL Server 2008还原数据库时出现“备份集中的数据库备份与现有的数据库不同”的解决方法引言 nbsp nbsp nbsp nbsp 现在在做项目 由于每个人是分模块的 所以大家的测试数据都不同步 导致好多时候会因为别人填的数据不同而调半天的错 所以我还是自己还原一个数据库 自己填自己的数据吧 nbsp nbsp 报错 nbsp nbsp nbsp nbsp nbsp 之前还原过很多个数据库都没什么问题 这次也是按照之前的步骤 先建立了一个目标数据库 之后选择源文件进行还原 最后报了这么一个错 解决方法 nbsp 1 nbsp 首先我们

    2025年6月20日
    1
  • eureka集群配置_hadoop高可用集群搭建

    eureka集群配置_hadoop高可用集群搭建Eruka高可用(集群)EurekaServer高可用配置(1)高可用是什么?“高可用性”(HighAvailability)通常来描述一个系统经过专门的设计,从而减少停工时间,而保持其服务的高度可用性如:给EurekaServer搞一个备份(2)服务同步原理多个EurekaServer之间也会互相注册为服务,当服务提供者注册到EurekaServer集群中的某个节点时,该节点会把服务的信息同步给集群中的每个节点,从而实现数据同步。因此,无论客户端访问到EurekaServer集

    2022年8月21日
    7
  • spring任务调度SchedulerFactoryBean、CronTriggerFactoryBean(简单,明了)[通俗易懂]

    spring任务调度SchedulerFactoryBean、CronTriggerFactoryBean(简单,明了)[通俗易懂]http://img.blog.csdn.net/20160530121730543?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Centerok,在控制台打印一句话,每隔一秒打印一次: 两步得到上述效果:…

    2022年5月24日
    43
  • Ubuntu18.04搭建源码搜索引擎Opengrok

    Ubuntu18.04搭建源码搜索引擎OpengrokTableofContents1OpenGrok介绍2安装OpenGrok2.1安装JAVA运行环境2.2安装Web服务器-Tomcat2.3安装OpenGrok2.4配置OpenGrok2.5安装 universal-ctags2.6建立源码索引2.6更新源码索引1OpenGrok介绍OpenGrok isafastand…

    2022年4月29日
    79

发表回复

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

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