Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raty problems with multiple instances? #27

Closed
felixchan opened this issue Dec 12, 2011 · 2 comments
Closed

Raty problems with multiple instances? #27

felixchan opened this issue Dec 12, 2011 · 2 comments

Comments

@felixchan
Copy link

Hi, when I do multiple instances of raty, it seems like Raty adds a half star even though it's a solid rating (4.0/3.0/2.0).

$(function(){
$('.star').each(function(el){
            $(this).raty({
                readOnly:true,
                path: 'media/template/js/raty/img',
                start: $(this).attr('data-rating'))
            });
});
});
<div class="detail_item star" data-rating='{{ r.rating }}'>
</div>
{{ r.rating }}

Here's an image: http://i.imgur.com/EXXlY.png (the score next to the stars is the string sent to Raty)

I've tried different things, like parseFloat(), Number(), String(), stripping the text, replacing the ".0" with "", ...but this problem still stays.

Any ideas? Thanks !

@wbotelhos
Copy link
Owner

Hi felix,

Maybe your r.rating is a float value, because it worked here:

<div data-rating='1' class="detail_item star"></div>
<div data-rating='2' class="detail_item star"></div>
<div data-rating='3' class="detail_item star"></div>
<script type="text/javascript">
    $(function() {

        $('.star').each(function(el){
            $(this).raty({
                readOnly:   true,
                start:      $(this).attr('data-rating')
            });
        });

    });
</script>

You can bind Raty direct and get the start value by callback like this:

$('.star').raty({
    start: function() {
        return $(this).attr('data-rating');
    }
});

But I see we have a issue on jQuery.index() where you can't use more than one class, then you should use just the class star. If you want put more style on it, do it by the class .star.

And you have a left parenthesis in your code.

@felixchan
Copy link
Author

Hi,

Thanks for the quick response!

I'm still getting the same error. Raty shows half-star ratings for solid-points.

Can you take a look here?

http://184.72.250.181/search/?q=ab

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants