2012-09-28 2 views
0

Jquery 함수에 약간의 어려움이 있습니다. 나는 언어에 대해 잘 모르기 때문에 누구든지 도울 수 있는지 궁금합니다.jquery - javascript 변수로 고민

$('.editableWC').editable('<?php echo base_url();?>ratesheet/editrowwendCall/<?=$editable['url'];?>/', 
     { 
     callback: function(value){ 
      $(this).data('bgcolor', $(this).css('background-color')); 
      if(value == this.revert) 
       {                    
       $(this).animate({ backgroundColor: "red", color: "white" }, 400); 
       $(this).animate({ backgroundColor: $(this).data('bgcolor'), color: "black" }, 400); 
       } 
      else 
       {                    
       $(this).animate({ backgroundColor: "green", color: "white" }, 400); 
       $(this).animate({ backgroundColor: $(this).data('bgcolor'), color: "black" }, 400); 
       } 
      }, 
     name : 'value', 
     style : 'display:inline; position:relative; right:120px;', 
     width : '100px', 
     height: '16px', 
     onblur : 'submit' 
    }); 

이것은 내 코드입니다. 단순히 PHP 유효성 검사에서 게시 된 항목을 검사하고 유효성 검사를 충족하지 못하면 원래 값을 다시 게시하고 그렇지 않으면 새 값을 게시합니다.

따라서 코드는 반환 값이 원본과 같고 변경이없는 경우 빨간색이 실패로 표시되고 성공하면 녹색으로 표시되는지 확인해야합니다 (값이 다른 경우). 녹색은 작동하지만 원래 값 post.revert 값과 동일하게 인식되지 않습니다.

이 코드는 값이 변경되지 않은 경우 녹색 = 값이 변경되면 유효성 검사 = 녹색을 나타냅니다. 값이 변경되면 유효성 검사 = 전혀 애니메이션이 적용되지 않습니다. 빨간색으로 깜박이기를 원할 때.

javascript에 관해서는 꽤 깊이 생각하고 있으므로 도움을 주시면 고맙겠습니다.

+0

검사'에서'cosnole.log' – EaterOfCode

답변

1

이 시도 :

$('.editableWC').editable('<?php echo base_url();?>ratesheet/editrowwendCall/<?=$editable['url'];?>/', 
    { 
    that:this, 
    callback: function(value){ 
     $(this.that).data('bgcolor', $(this.that).css('background-color')); 
     if(value == this.that.revert) 
      {                    
      $(this.that).animate({ backgroundColor: "red", color: "white" }, 400); 
      $(this.that).animate({ backgroundColor: $(this.that).data('bgcolor'), color: "black" }, 400); 
      } 
     else 
      {                    
      $(this.that).animate({ backgroundColor: "green", color: "white" }, 400); 
      $(this.that).animate({ backgroundColor: $(this.that).data('bgcolor'), color: "black" }, 400); 
      } 
     }, 
    name : 'value', 
    style : 'display:inline; position:relative; right:120px;', 
    width : '100px', 
    height: '16px', 
    onblur : 'submit' 
}); 
+0

와 this.revert' 당신이 가까이있어 뭐죠 .. – EaterOfCode

관련 문제