Jquery 关闭对话框时,再次打开时不要删除以前的内容
我在该对话框中创建了一个对话框和一个UI选项卡。在该对话框中,我以表格的形式显示一些内容。当我用remove()方法关闭对话框时,它会关闭对话框,但当我重新打开它时,旧内容仍会与新内容一起显示在选项卡中,是否有旧内容在对话框关闭时也会重新显示的方法。我使用了empty(),但下面是我的代码Jquery 关闭对话框时,再次打开时不要删除以前的内容,jquery,html,jquery-ui,Jquery,Html,Jquery Ui,我在该对话框中创建了一个对话框和一个UI选项卡。在该对话框中,我以表格的形式显示一些内容。当我用remove()方法关闭对话框时,它会关闭对话框,但当我重新打开它时,旧内容仍会与新内容一起显示在选项卡中,是否有旧内容在对话框关闭时也会重新显示的方法。我使用了empty(),但下面是我的代码 this.formOrderList = null; this.orderListDialogObject = $('<div id="mainDiv"></div>'); this.
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);
this.formOrderList=null;
this.orderListDialogObject=$('');
this.orderListTable=$(“”
+ ''
+ '' + ''
+“订单#”
+“符号”
//+“交换”
//+“市场”
+“时间”
+“订单类型”
+“侧'
+“音量”
+“价格”
+“触发价格”
+“填充卷”
+“状态”
+“有效期”
+“参考#”
+“动作”“++”
+ '' + '' + '' + '');
this.orderListTabs=$(“”+”'
+“”+“
”
+ '' + '' + '');
this.orderListDialogObject.appendTo(“body”);
this.show=函数(){
$(“#orderListBody”,this.orderListTable).empty();
this.orderListDialogObject.dialog({
title:'订单列表',
宽度:850,
身高:150,
关闭:功能(ev、ui){
$(this.remove();
返回false;
/*$(this.dialog('destroy').remove();
返回false*/
}
});
this.orderListTabs.tabs();
this.orderListTabs.appendTo(this.orderListDialogObject);
$(“#pendingOrderList”,this.orderListTabs).append(this.orderListTable);
我不完全理解,但是如果您需要删除该表,那么您可以将其删除
//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");
}
});
问题是当我在对话框中显示一个表时。当我关闭对话框后重新打开时,旧的内容仍然会显示。例如,tableA的值为“1 2 3”,下次我重新打开它时,它会显示为“1 2 3 1 2 3”,而必须再次显示为“1 2 3”我已经试过你的代码,当我再次打开它时,表没有显示出来。@Java_NewBie你能在jsFiddle.net上提供一个例子吗?Nicola现在真的很难把它放在小提琴上,但我可以给你一篇我在两个月前就同一个问题发表的帖子,当时它起作用了。这是我发布的问题@Java_NewBie have的链接您尝试使用了
“关闭”
而不是“销毁”
?