nashio / star-rating-svg

A star rating jQuery plugin that uses SVG for easier customization
http://nashio.github.io/star-rating-svg/demo
MIT License
355 stars 156 forks source link

re-initialize a star rating #6

Closed binskeep closed 8 years ago

binskeep commented 8 years ago

I tried to re-initialize a star rating with new initialRating. The previous initialRating remained. How do you go about doing it?

nashio commented 8 years ago

Hi @binskeep , can you elaborate a bit more?. Not sure what you mean by the previous initialRating. There's only one initialRating, the one you use to load the first time.

binskeep commented 8 years ago

User case: I have a 'read only' starRating that displays the average of everyones starRating. I have another starRating that allows the operator to enter the operator's starRating. When the ajax call returns from the updating the operator's starRating, I need to update the 'read only' starRating. It has already been initialized and displayed. However I need to be able to update the 'read only' with the new average. I ended up unloading and erasing the 'read only' starRating, then rebuilding a new 'read only' starRating. It would be nice to allow updating the initialRating after it's been loaded.

nashio commented 8 years ago

I get you now, good point. I'm gonna add a new method to update the current rating.

nashio commented 8 years ago

@binskeep Added a couple of new methods, let me know if that works for you

// set rating example  
$('your-selector').starRating('setRating', 2.5)  
// get rating example  
$('your-selector').starRating('getRating')  
binskeep commented 8 years ago

Hi Nashio, I just downloaded v1.0.1 That did the trick. I don't have to unload/reload the plugin. Thanks!