Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have a web service that updates a databound row, on success I want the row to highlight green then change back to its original color but I am having the most difficulty accomplishing the easiest part (the animate). Here is my javascript code, it works up until the animate part:

C#
<script type="text/javascript">

    function lbUpdateCriteria_Click(srcEl) {
        var vId = srcEl.getAttribute("CriteriaVestingId");
        var currentTr = $(srcEl).closest("tr");
        var typeId = currentTr.find("[getValue=ddlVestingCriteriaType" + vId + "]").val();
        var lowerBound = currentTr.find("[getValue=tbLowerBound" + vId + "]").val();
        var upperBound = currentTr.find("[getValue=tbUpperBound" + vId + "]").val();
        UpdateVestingCriteria(vId, typeId, lowerBound, upperBound, currentTr);

    }
    function UpdateVestingCriteria(vId, typeId, lowerBound, upperBound, currentTr) {
        var webMethod = "../Service/UpdateCriteria.asmx/UpdateNewCriteria";
        var parameters = "{'criteriaVestingId':'" + vId + "','criteriaTypeId':'" + typeId + "','lowerBound':'" + lowerBound + "','upperBound':'" + upperBound + "'}";
        $.ajax({
            type: "POST",
            url: webMethod,
            data: parameters,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {

// This is where it breaks....
                currentTr.animate({ backgroundColor: "#48B84B" }, 1000);
                //currentTr.css("backgroundColor", "#48B84B");
                //                setTimeout(function () { $(currentTr).effect("highlight", { color: "#FFFFFF" }, 2000); }, 2000);


            },
            error: function (e) {
                debugger;
                alert(e.statusText)
            }
        });
    }
</script>


When it gets to the line currentTr.animate({...}) it throws this error
Microsoft JScript runtime error: Object doesn't support this property or method


I've checked my jqueryui is the latest version 1.8.22, I've also tried other jqueryUI functions like css that do work correctly on the row. I don't know what else could be the problem. I've tried googling the error and nothing relavent to me comes up. Any help or suggestions would be greatly appreciated.
Posted
Updated 31-Aug-12 5:00am
v3
Comments
AmitGajjar 31-Aug-12 11:16am    
There may be issue with the TR. i suggest you to add Div tag in your cell and try with the same. let me know if it works.
ModestMonk 31-Aug-12 13:47pm    
Sadly still breaks.
AmitGajjar 1-Sep-12 0:16am    
are you getting correct TR using closest?
ModestMonk 4-Sep-12 9:38am    
Yeah, I can alter the color without the animation correctly but the animation crashes when I try to do it.
AmitGajjar 5-Sep-12 0:14am    
Which browser you are using ?

1 solution

http://api.jquery.com/animate/
check here

All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color() plugin is used). Property values are treated as a number of pixels unless otherwise specified. The units em and % can be specified where applicable.

you need add twice to your page




you can find more detail from this page https://github.com/jquery/jquery-color[^]
 
Share this answer
 
Comments
ModestMonk 4-Sep-12 10:45am    
Works, just had to add JQuery color due to it being background-color. Thanks bunches
Dain Ucak 4-Sep-12 10:53am    
you welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900