Javascript 重复记录显示
为什么在运行代码时会显示重复内容?我使用empty()在重新运行时删除以前的记录,但它似乎也不起作用 这是我的密码:Javascript 重复记录显示,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,为什么在运行代码时会显示重复内容?我使用empty()在重新运行时删除以前的记录,但它似乎也不起作用 这是我的密码: function listClass() { this.formOrderList = null; this.orderListDialogObject = $('<div id="mainDiv"></div>'); this.orderListTable = $('<div>' + '<table id="orderListT
function listClass() {
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);
}
函数listClass(){
this.formOrderList=null;
this.orderListDialogObject=$('');
this.orderListTable=$(“”
+ ''
+ '' + ''
+“订单#”
+“符号”
//+“交换”
//+“市场”
+“时间”
+“订单类型”
+“侧边”
+“音量”
+“价格”
+“触发价格”
+“填充卷”
+“状态”
+“有效期”
+“参考#”
+“动作”“++”
+ '' + '' + '' + '');
this.orderListTabs=$(''+''
+“”+“
”
+ '' + '' + '');
this.orderListDialogObject.appendTo(“body”);
this.show=函数(){
$(“#orderListBody”,this.orderListTable).empty();
this.orderListDialogObject.dialog({
标题:“订单列表”,
宽度: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);
}
您在函数中引用了此
,因此它指向全局对象
这里有一个解决方法:
var that = this;
this.show = function() {
$("#orderListBody", that.orderListTable).empty();
that.orderListDialogObject.dialog({
title : 'Order List',
width : 850,
height : 150,
close : function(ev, ui) {
$(this).remove();
return false;
/*$(this).dialog('destroy').remove();
return false;*/
}
});
我已使用您的代码生成,但无法复制内容。scessor not in the ad,在t正文中显示重复的内容。在()您看到一个填充了
tbody
的示例,重复的内容没有问题。Scissor它以前工作正常,我不知道为什么现在不工作。我必须再次看到它。我知道。但是您在一个匿名函数中引用了此
,该函数与您的类没有绑定。因此此
将指向全局对象,可能是窗口
。