使用新对话框打开旧对话框

时间:2011-03-26 08:40:19

标签: jquery-ui jquery-ui-dialog

您好 我正在使用jquery对话框,当我从atable中选择一条记录时,它会调用对话框,然后当我关闭它并选择另一条记录时,它会打开带有新对话框的旧对话框...问题是什么< / p>

$(document).ready(function () {
    $("#btnenterpat").click(function () {
        $("#enter_payment").dialog('open');
    });
    $("#enter_payment").dialog({
        autoOpen: false,
        resizable: false,
        modal: true,
        width: 400,
        height: 300,
        buttons: {
            Cancel: function () {
                $(this).dialog('close');
            },
            ok: function () {
                retur_dialog = 'ok';
                $(this).dialog('close');
            },
        },
        beforeClose: function () {
            if (retur_dialog == 'ok') {
                $.ajax({
                    url: 'ssssssss.php',
                    data: {
                        pm1: $("#pm1").val(),
                        pm2: $("#pm2").val(),
                        pm3: $("#pm3").val(),
                        pm4: $("#pm4").val(),
                        pm5: $("#pm5").val(),
                        pm6: $("#pm6").val(),
                        pm7: $("#pm7").val(),
                    },

                });
            }
        }
    });
});

编辑:

第一页:

<?php
    include ("angela_test.php")
?>
<div style="font-size:12px;">
</div>
<br />
<table id="tbl_angela_test_data"></table>
<div id="p_angela_test_data"></div>
<script type="text/javascript">
$(document).ready(function(){
    var selected_id;
    var colCap = Array();
    var colDef = Array();
    var grp_filter = 0;

      $.ajax({
         url: "getColDefs.php" ,
         data: {table: "bk_accounts", userid: "5", groupid: "1"},
         dataType: "json",
         async: false,
         success: function (data) {
                colCap = data[0];
                colDef = data[1];
         }
      });

    var cols = '';
    for(i=0; i<colDef.length; i++) {
        cols += colDef[i].name;
        if (i != (colDef.length-1)) {
            cols += ';';
        }
    }

    jQuery("#tbl_angela_test_data").jqGrid({
        url:'admin/angela_test_table_get.php',  
        postData: {columns: cols},
        datatype: 'json',
        mtype: 'POST',
        height: 'auto',
        width: 'auto',
        rowNum: 20,
        rowList: [10,20,30],
        colNames: colCap,
        colModel: colDef,
        pager: "#p_angela_test_data",
        viewrecords: true,
        toolbar: [true, 'both'],
        caption: "angela_test",
        onSelectRow: function(id){
            selected_id = id;
            $("#angela_test_del_bnt, #angela_test_edit_bnt").attr("disabled", false);
            }
    });
    jQuery("#tbl_angela_test_data").setGridWidth(500);

    $("#t_tbl_angela_test_data").height(40);
    $("#t_tbl_angela_test_data").append('<button id="angela_test_edit_bnt" style="height:30px; width:100px;" disabled="true">Edit</button>');


    // edit button
    $("#angela_test_edit_bnt").click(function(){
        var rw = '#angela_test_item_'+selected_id;
        var maintab = $("#tabs");
        if ($(rw).html() != null) {
            maintab.tabs('select',rw);
        } else {
            maintab.tabs('add',rw,'Edit form');
           $(rw, '#tabs').load('admin/angelatest.php?id='+selected_id);
        }
    });


//////////////////////////////
})
</script>

,第二页是:

<?php
 include_once("angela_test.php"); 
?>
<input type="button" id="btnenterpat" value="Enter Payment">

,对话框代码为:

<script type="text/javascript">

$(document).ready(function () {
    $("#btnenterpat").click(function () {
        $("#angela_test").dialog('open');
    });

    $("#angela_test").dialog({

        autoOpen: false,
        resizable: false,
        modal: true,
        width: 400,
        height: 300,
        buttons: {
            Cancel: function () {
                $(this).dialog('close');
            },
            ok: function () {
                $(this).dialog('close');
            },
        },
    }).parent().find(".ui-dialog-titlebar-close").hide();
});
</script>

<!--Enter Payment windows --> 
<div id="angela_test" ></div>
<!--dialog windows end -->

1 个答案:

答案 0 :(得分:0)

调用$('#some-div').dialog('destroy')会在调用#some-div之前将$('#some-div').dialog(...)元素恢复为原始格式。也许你可以考虑在关闭对话框时这样做吗?