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

Setting 'single' parameter to true doesn't work if the score parameter is set as well #58

Closed
levani opened this issue Feb 4, 2013 · 2 comments

Comments

@levani
Copy link

levani commented Feb 4, 2013

This is the code I tried to make a simple animation with stars. What it does is to select only one star in a row.

var x = 1;
var i = setInterval(function() {
    $('.starRating').raty({
        single: true,
        score: x
    });
    x++;
    if ( x > 5 )
        clearInterval(i);
}, 200);

but it doesn't select only one star, but all the start before and including x. Any ideas?

@wbotelhos
Copy link
Owner

You can't bind the Raty more than one time on the same .starRating.
Try to bind one time outside the interval and than to use $('.starRating').raty('score', x);

I can't test your code now, tonight I will try it.

@wbotelhos
Copy link
Owner

You should bind just one time and use the function to change the score:

var star = $('#star'),
    i    = 1;

star.raty({ single: true });

var time = setInterval(function() {
  star.raty('score', i++);

  if (i > 5) {
    i = 1;
  }
}, 200);

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