Using the jQuery Star Rating plugin everything works well until I select a star rating from the rating's callback handler. Simple example:
$('.rating').rating({
...
callback: function(value){
$.ajax({
type: "POST",
url: ...
data: {rating: value},
success: function(data){
$('.rating').rating('select', 1);
}
});
}
});
I'm guessing this infinite loop occurs because the callback is fired after a manual 'select' as well. Once a user submits their rating I'd like to 'select' the average rating across all users (this value is in data returned to the success handler).
How can I do this without triggering an infinite loop?
They have terrible documentation.
Digging through the source code, you will find that the "select" function takes an additional parameter wantCallBack. So set that to false:
$('.rating').rating('select', 1, false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With