2010-12-31 2 views
0

<tr />의 배경을 변경하면서 AJAX 청원서에서 수정 된 필드를 알리려고하고 있지만 제대로 작동하지 않습니다.jQuery는 실제 CSS 배경색을 저장하고 새로운 것을 적용한 다음 원본을 복원합니다.

내 코드는 AJAX 청원을 포함하지만 문제가 함께이 권리 처리 :

var $this = $(this); 
if(confirm("Delete?")) 
{ 
    // My AJAX petition returns TRUE or FALSE, if TRUE: 

    // Store the ORIGINAL color 
    var ORIGINAL = $this.closest("tr.entry").css('backgroundColor'); 

    // The alert works fine 
    alert(ORIGINAL); 

    // Change the color with the desired and then change with the original after a delay. 
    // If i dont use the delay() and the second css() works fine. 

    $this.closest("tr.entry").css('backgroundColor','#ace997').delay(500).css('backgroundColor', ORIGINAL); 
} 

사전에 감사를!

+0

jQuery 1.4를 사용하고 계십니까? – BoltClock

+0

@BoltClock : 예, 있습니다. – ipalaus

+0

첫 줄에 var $ this = $ (this);를 읽어야합니다. – bozdoz

답변

1

JQuery와 .delay() 방법의 jQuery 효과를 사용하여 상기 효과의 큐를 관리한다하다. 사용하지 않으므로 setTimeout을 사용해야합니다.

$this.closest("tr.entry").css('backgroundColor','#ace997'); 

window.setTimeout(function(e) { 
    return function() { 
     e.css('backgroundColor', ORIGINAL); 
    } 
}($this.closest('tr.entry')), 500); 
0

confirm() if 문에 closing parenthasis가 없습니다.

if(confirm("Delete?")

if(confirm("Delete?"))

관련 문제