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

Set Rating dynamically #25

Open
andrew-za opened this issue Sep 2, 2016 · 4 comments
Open

Set Rating dynamically #25

andrew-za opened this issue Sep 2, 2016 · 4 comments

Comments

@andrew-za
Copy link

When i use this:

$('.starrr').starrr({ rating: $(this).attr('data-rating'),

It does not set the rating...

@DevCobe
Copy link

DevCobe commented Oct 10, 2016

i had to hack it this way

function Starrr($el, options) { _this.defaults.rating = ($el.data('rating'))? $el.data('rating'):0;_ this.options = $.extend({}, this.defaults, options); this.$el = $el; this.createStars();

i added this to the defaults
this.defaults.rating = ($el.data('rating'))? $el.data('rating'):0;
after line 15

works for me as defaults

hope it helps. God bless you all @dobtco

@mauriciorbernardo
Copy link

Perfect! Thank you!

@axedaddy
Copy link

I had to hack it as well, but did a little differently, I added this after line 88.

      return this.each(function () {
        var data;
        data = $(this).data('starrr');
        var rating = $(this).attr('data-rating');     // Added this
        if (rating) {
            option.rating = rating;
        }
       ...

@benjbaron
Copy link

With the current version, you can just do the following: el.starrr("setRating", 3).

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

5 participants