dreyescat / bootstrap-rating

Bootstrap Rating is a jQuery plugin that creates a rating control that uses Bootstrap glyphicons for rating symbols.
http://dreyescat.github.io/bootstrap-rating/
MIT License
192 stars 78 forks source link

Programatically set the value #13

Closed therocode closed 9 years ago

therocode commented 9 years ago

Hello!

Is it at all possible to set the value of a bootstrap-rating displayer programatically? I noticed another issue posted about it but it was subsequently closed without any information on a solution. Regards

dreyescat commented 9 years ago

First of all, thanks @therocode for the feedback.

I saw that issue that you mention. Yes, it was created and immediately closed afterwards by the same user. So I just ignored the issue.

Following your suggestion, I think I will add some explicit method to the plugin to set the value programmatically. But in the meantime, you can accomplish more or less the same effect simulating the change event on the associated input. Something like this:

<input type="hidden" class="rating" id="programmatically-rating">
$('#programmatically-rating').val(3).change();

Anyway, I am planning to add that method to explicitly set the value programmatically.

therocode commented 9 years ago

Thanks for the reply!

It's nice to see that this could end up an improvement for the library. IMHO adding such a function would make sense since it's not a farfetched thing to want to do.

The meanwhile-solution works well! Thanks for that, and for the library itself!

I'll leave this open in case you want to keep it until said feature is implemented. Otherwise, feel free to close it.

dreyescat commented 9 years ago

Done!

Added a rate setter/getter.