2012-02-02 57 views
1

我已經在該對話框中做了一個對話框和UI標籤。在那個對話框中,我將一些內容顯示爲一張表格。當我通過remove()方法關閉對話框時,它會關閉對話框,但是當我重新打開它時,舊內容仍然顯示在選項卡中的新內容中,是否有任何方法在關閉對話框時還會重新顯示舊內容。我用空(),但它似乎無用下面是我的代碼。關閉對話框不要刪除以前的內容再次重新打開

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); 

回答

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"); 
    } 
}); 
+0

很好的問題是,當我在一個對話框中顯示的表。當我在關閉對話框後重新打開時,舊的內容仍然顯示出來。例如tableA在我下次重新打開時的值爲「1 2 3」,它顯示爲「1 2 3 1 2 3」,而不是必須再次顯示。 「1 2 3」 – 2012-02-02 09:29:20

+0

我試過了我的代碼,當我重新打開它時,表格沒有顯示出來。 – 2012-02-02 09:41:37

+0

@Java_NewBie你能提供一個關於jsFiddle.net的例子嗎? – 2012-02-02 09:45:12

相關問題