0
<script type="text/javascript">
                    var $stars = $("#formStars{{ item.url }}")
                    $stars.click(function(){
                        var value = $("input:radio[name={{ item.url }}]:checked", this).val(),
                            item = "{{ item.url }}",
                            user = "{{ user }}";

                        $.ajax({
                            type: "GET",
                            url: "/addvote/",
                            data: "item="+item+"&user="+user+"&value="+value,
                            success: function(){
                                $("input:radio[name="+item+"]").attr("disabled", "disabled");
                            }
                        });
                    });             
                </script>

Don't work the success function, input not disabled, but if i reload the page it becoms disabled...

2
  • is there any error in your console.use firbug Commented Jul 9, 2011 at 9:12
  • Any luck getting this to work? Commented Jul 9, 2011 at 9:56

1 Answer 1

3

Try wrapping your function in the a document.ready

$(document).ready(                    
                    var $stars = $("#formStars{{ item.url }}")
                    $stars.click(function(){
                        var value = $("input:radio[name={{ item.url }}]:checked", this).val(),
                            item = "{{ item.url }}",
                            user = "{{ user }}";

                        $.ajax({
                            type: "GET",
                            url: "/addvote/",
                            data: "item="+item+"&user="+user+"&value="+value,
                            success: function(){
                                $("input:radio[name="+item+"]").attr("disabled", "disabled");
                            }
                        });
                    }); 
);

This makes sure the dom elements are loaded before attempting to manipulate them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.