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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.