tcallsen / jquery-star-rating-plugin

Automatically exported from code.google.com/p/jquery-star-rating-plugin
0 stars 0 forks source link

Javascript error when pressing erase button #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Use the following html with a folder called starrate where the .zip file is 
extracted

2. Code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body>
<script src='starrate/jquery.js' type="text/javascript" 
language="javascript"></script>
<script src='starrate/jquery.MetaData.js' type="text/javascript" 
language="javascript"></script>
<script src='starrate/jquery.rating.js' type="text/javascript" 
language="javascript"></script>
<link href='starrate/jquery.rating.css' type="text/css" rel="stylesheet" />
<form action="#" method="post" class="stdform" id="ratingform">
<input type="radio" class="starrate" name="the_rating" value="1" id="rate1" 
title="choice 1" />
<input type="radio" class="starrate" name="the_rating" value="2" id="rate2" 
title="choice 2" /> 
<input type="radio" class="starrate" name="the_rating" value="3" id="rate3" 
title="choice 3" checked="checked" /> 
<input type="radio" class="starrate" name="the_rating" value="4" id="rate4" 
title="choice 4" /> 
<input type="radio" class="starrate" name="the_rating" value="5" id="rate5" 
title="choice 5" />
<span id="choice" style="margin:0 0 0 20px;">choice 0</span>
</form>
<script type="text/javascript">
    $(function () {
        $('#ratingform input:radio[name="the_rating"]').rating({
            focus: function(value, link){
                var tip = $('#choice');
                tip[0].data = tip[0].data || tip.html();
                tip.html(link.title || 'value: '+value);
            },
            blur: function(value, link){
                if ( !this.checked ) {
                    var tip = $('#choice');
                    $('#choice').html(tip[0].data || '');
                }
            }, 
            callback: function(value, link){
            }
        });
    });
</script>
</body>
</html>

3. Clicking on the 'erase' button results in an error.

What is the expected output? What do you see instead?
There should be no error, instead I get "Uncaught TypeError: Cannot set 
property 'checked' of undefined / jquery.rating.js:303" in Chrome and a similar 
error in IE9.

What version of the plugin/jQuery are you using?
PLUGIN VERSION: jQuery Star Rating Plugin v4.01 - 2013-02-23
JQUERY VERSION: jQuery JavaScript Library v1.9.1

On what browser(s) or operating system?
BROWSER(S): Chrome 25.0.1364.97 and IE9 on Windows 7

Please provide a link to where the problem can be observed:
URL: non provided, see code above

Feel free to provide any additional information below.
This is the line that produces the error:
$(input)[0].checked=true;
I made a breakpoint so I could debug it and it turns out control.current is 
null, then input becomes null.
Updating all the files from the .zip from www.fyneworks.com with the files here 
on code.google.com I found out the line got changed into:
$(input).attr('checked','checked')[0].checked=true;
But I still get an error

Original issue reported on code.google.com by gassiusg...@gmail.com on 28 Feb 2013 at 5:33

GoogleCodeExporter commented 9 years ago
We found the problem, we're making the changes now!

Original comment by diego.a...@gmail.com on 28 Feb 2013 at 5:41

GoogleCodeExporter commented 9 years ago
The latest revision works (v4.03)

We've also tested it with your code: http://jsfiddle.net/spinal007/PhdqR/

Original comment by diego.a...@gmail.com on 28 Feb 2013 at 6:20

GoogleCodeExporter commented 9 years ago
Yes it does! Thanks

Original comment by gassiusg...@gmail.com on 28 Feb 2013 at 8:14