Chinaunix首页 | 论坛 | 博客
  • 博客访问: 695313
  • 博文数量: 160
  • 博客积分: 8847
  • 博客等级: 中将
  • 技术积分: 1656
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-25 16:46
个人简介

。。。。。。。。。。。。。。。。。。。。。。

文章分类

全部博文(160)

文章存档

2015年(1)

2013年(1)

2012年(4)

2011年(26)

2010年(14)

2009年(36)

2008年(38)

2007年(39)

2006年(1)

分类:

2010-11-25 10:51:17


主页源码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>dialog</title>


    <link rel="stylesheet" type="text/css" href="css/ui/jquery-ui.css" />

    <link rel="stylesheet" type="text/css" href="css/main.css" />

    <script src="js/jquery.js" type="text/javascript"></script>

    <script src="js/jquery.ui.js" type="text/javascript"></script>

    <script src="js/jquery.js" type="text/javascript"></script>

    <script src="js/jquery.ui.js" type="text/javascript"></script>

    <script src="js/main.js" type="text/javascript"></script>

</head>

<body>

    <div id="container"></div>

    <div>

        <input type="image" id="dialogButton" src="imgs/add.PNG" />

    </div>

    <div id="dialogForm"></div>

</body>

</html>



弹出对话框代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

<html>

    <head>

        <meta http-equiv="content-type" content="text/html; charset=utf-8" />

        <title></title>

        <script type="text/javascript" src="js/dialog.js"></script>

    </head>

    <body>

        <div id="dialog-form" title="新建用户">

            <fieldset>

                <div>

                    <label>姓名:</label>

                    <input type="text" name="name" id="name" value="" class="text ui-widget-content ui-corner-all" />

                </div>               

            </fieldset>

        </div>

    </body>

</html>



main.js

$(document).ready(function() {

    $.ajaxSetup({cache: false});

    $("#dialogButton").live("click",function(){

        $.ajax({

            url: "dialog/dialog.html",

            cache: false,

            dataType: "html",

            type: "get",

            success: function(html){

                $("#dialogForm").html(html);

                $("#dialog-form").dialog("open");

            },

            error: function(msg){

                alert("error");

            }

        });

    });

});



dialog.js

(document).ready(function(){

    $( "#dialog-form" ).dialog({

        height: 'auto',

        width: 300,

        modal: true,

        autoOpen: false,

        cache: false,

        buttons: {

            "OK": function() {

                var name = $("input#name").val();
                //将结果通过post方式传给方法,并可能写入数据库


                $.post("", {name: name}, function(msg){

                    //ajax返回结果 -- msg

                    switch msg
                        case
                            ....; break;
                    default: ...

                });



                

                $(this).dialog( "close");

                $("#dialogForm").empty();

            },

            "Cancle": function() {

                $( this ).dialog( "close" );

                $("#dialogForm").empty();

            }

        },

        close: function() {

            $( this ).dialog( "close" );

            $("#dialogForm").empty();

        }

    });

});


阅读(2306) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-25 16:24:54

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com