0

Jquery関数に少し問題があります。言語がよくわからないので、誰か助けてくれないかと思います。

$('.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検証で投稿されたアイテムをチェックするだけで、検証に適合しない場合は元の値に、適合している場合は新しい値にポストバックされます。

したがって、コードは、戻り値が元の値と同じであるかどうかを確認し、変更がない場合は、失敗した場合は赤、成功した場合は緑(値が異なる場合)を表示することになっています。緑は機能しますが、元の値のポストバックがthis.revert値と同じであるとは認識されません。

このコードで何が起こるかは、値が変更されていない場合=値が変更されて検証が満たされている場合は緑=値が変更されている場合は緑であり、検証が満たされていない=アニメーションがまったくない場合です。赤く点滅したいとき。

javascriptに関しては、私は自分の深みからかなり外れているので、助けていただければ幸いです。

4

1 に答える 1

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' 
 });
于 2012-09-28T12:27:11.507 に答える