美文网首页
easyui的window学习

easyui的window学习

作者: 全栈未遂工程师 | 来源:发表于2016-03-15 11:06 被阅读191次

目的:弹出、关闭window。
效果图:

window效果图
代码:/EasyUiLearn/WebContent/window/index.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>
<%String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="<%=basePath %>">
    <title>window</title>
    <!--
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.4.3/themes/default/easyui.css">
    --> 
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.4.3/themes/bootstrap/easyui.css">
     
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.4.3/themes/icon.css">
    <script type="text/javascript" src="jquery-easyui-1.4.3/jquery.min.js"></script>
    <script type="text/javascript" src="jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
</head>
<script>
var windowMain = {
    initWindow:function(){
        $("#win").window({
            title:"一个弹出窗口",
            width:600,
            height:400,
            modal:true,
            closed:true,
            href:"window/window.jsp",
            onLoad:function(){
                console.log('页面加载完成调用!');
                //为新加载的页面控件绑定事件
                $("#closeBtn").click(function(){
                    $("#win").window("close");
                });
            }
        });
    }
}
$(function(){
    windowMain.initWindow();
});

function openWin(){
    $("#win").window("open");
}
</script>
<body>
<a href="javascript:void(0);" class="easyui-linkbutton" onClick="javascript:openWin();">打开</a><br><br>
<div id="win"></div>
</body>
</html>

window代码:/EasyUiLearn/WebContent/window/window.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<div class="easyui-panel" style="padding:10px;">
    <form id="ff" action="form1_proc.php" method="post" enctype="multipart/form-data">
        <table>
            <tr>
                <td>Name:</td>
                <td><input name="name" class="f1 easyui-textbox"></input></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input name="email" class="f1 easyui-textbox"></input></td>
            </tr>
            <tr>
                <td>Phone:</td>
                <td><input name="phone" class="f1 easyui-textbox"></input></td>
            </tr>
            <tr>
                <td>File:</td>
                <td><input name="file" class="f1 easyui-filebox"></input></td>
            </tr>
            <tr>
                <td><a id="closeBtn" class="easyui-linkbutton" href="javascript:void(0)">关闭</a></td>
                <td></td>
            </tr>
        </table>
    </form>
</div>

要点:

  1. 页面添加window div。
    <div id="win"></div>
  2. window初始化。
    $("#win").window({})
    页面就在完成后调用window初始化。windowMain.initWindow();
  3. window加载完成调用onLoad,在这个方法中给window.jsp页面的控件绑定事件。
  4. 打开window。$("#win").window("open");
  5. 关闭window。$("#win").window("close");

源码下载

相关文章

网友评论

      本文标题:easyui的window学习

      本文链接:https://www.haomeiwen.com/subject/tbtqlttx.html