How can I use Rate Yo jQuery star rating plugin with data attribute?

Viewed 5996

How can I use Rate Yo jQuery star rating plugin with data attribute?
Is there any way to set a default initial value via HTML attribute?
Is it possible using data-rateyo-score to pass the score value.

For example, If I want to start my score depending on a dynamic value, How can I use callback for it?

My code is same as below:
<div class="rateYo" data-rateyo-score="1"></div>

I try below code:

$('.rateYo').rateYo({
  score: function() {
    return $(this).attr('data-rateyo-score');
  }
});

and this:

$('.rateYo').rateYo({
  score: $(this).attr('data-rateyo-score');
  }
});

But it seems that something is wrong.

2 Answers

Set default rating value when readOnly option: true

Related