2012-02-07 3 views
0

코드를 실행할 때 중복되는 내용이 표시되는 이유는 무엇입니까? 다시 실행시 이전 레코드를 제거하기 위해 empty()를 사용하고 있지만 작동하지 않는 것 같습니다.중복 레코드 표시

여기 내 코드입니다 : 당신은 함수 내부 this 참조하고

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

[예] (http://jsfiddle.net/pnNNU/) 코드와,하지만 HTTP ([보기] 수 없습니다 : // jsfiddle을 .net/pnNNU/show /) 중복 콘텐츠. – scessor

+0

scessor in thead, tbody에서는 중복 된 내용을 표시합니다. –

+0

그리고 어떤 함수가'tbody'를 채 웁니 까? [이 예제에서는] (http://jsfiddle.net/pnNNU/1/show/) ([코드는 여기에 (http://jsfiddle.net/pnNNU/1/)) 채워진 예제를 볼 tbody 중복 콘텐츠에 대해서는 아무런 문제가 없습니다. – scessor

답변

1

, 그래서 전역 객체를 가리키는 것. 여기

는 해결 방법입니다 : 내가 구축

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

외국인,이 코드는 이미 클래스에 있습니다. –

+0

나는 알고있다. 클래스에 바인딩되지 않은 익명의 함수 안에서'this'를 참조하고 있습니다. 따라서'this'는 전역 객체를 가리키고, 아마도'window'를 가리킬 것입니다. – AlienWebguy

+0

나는 그것을 시도했다, 그것도 작동하지 않습니다. –