关闭对话框时,不要再次重新打开以前的内容

时间:2012-02-02 09:17:36

标签: jquery html jquery-ui

我在该对话框中创建了一个对话框和一个UI选项卡。在该对话框中,我将一些内容显示为表格。当我通过remove()方法关闭对话框时它会关闭对话框,但是当我重新打开它时,旧内容仍然显示在选项卡中的新内容,是否存在任何方法,当对话框关闭时旧内容也会重新显示。我使用了empty(),但下面似乎无用是我的代码。

this.formOrderList = null;
this.orderListDialogObject = $('<div id="mainDiv"></div>');
this.orderListTable = $('<div>'
        + '<table id="orderListTable" class="ui-widget tblBorder" width="100%" border="0"  cellspacing="1" cellpadding="2">'
        + '<thead class="ui-widget-header" id="orderListHead">' + '<tr>'
        + '<th><strong> Order# </strong></th>'
        + '<th><strong> Symbol </strong></th>'
        //+ '<th><strong> Exchange </strong></th>'
        //+ '<th><strong> Market </strong></th>'
        + '<th><strong> Time </strong></th>'            
        + '<th><strong> Order Type </strong></th>'
        + '<th><strong> Side </strong></th>'
        + '<th><strong> Volume </strong></th>'
        + '<th><strong> Price </strong></th>'
        + '<th><strong> Trigger Price </strong></th>'
        + '<th><strong> Filled Volume </strong></th>'
        + '<th><strong> Status </strong></th>'
        + '<th><strong> Expiry Date </strong></th>'
        + '<th><strong> Ref # </strong></th>'
        + '<th><strong> Action </strong></th>' + '</tr>' + '</thead>'
        + '<tbody id="orderListBody">' + '</tbody>' + '</table>' + '</div>');
this.orderListTabs = $('<div>' + '<ul>'
        + '<li><a href="#pendingOrderList">Pending</a></li>' + '</ul>'
        + '<div id="pendingOrderList">' + '</div>' + '</div>');
this.orderListDialogObject.appendTo("body");
this.show = function() {
    $("#orderListBody", this.orderListTable).empty();
    this.orderListDialogObject.dialog({
        title : 'Order List',
        width : 850,
        height : 150,           
        close : function(ev, ui) {
            $(this).remove();
            return false;
            /*$(this).dialog('destroy').remove();
            return false;*/
        }
    });
    this.orderListTabs.tabs();
    this.orderListTabs.appendTo(this.orderListDialogObject);        
    $("#pendingOrderList", this.orderListTabs).append(this.orderListTable);

1 个答案:

答案 0 :(得分:0)

我完全不了解,但是如果您需要删除该表,那么您可能只是删除它

//Save a reference of the dialog
var myDialog  =  this.orderListDialogObject.dialog({
    title : 'Order List',
    width : 850,
    height : 150,           
    close : function(ev, ui) {
         //remove the table
         $('table#orderListTable').remove();
         //close the dialog destroing it
         myDialog.dialog("close");
    }
});