JQuery Star Rating plugin - selection in callback causes endless loop

Using the jQuery Star Rating plugin, everything worked well until I selected a star rating from the rating callback handler. A simple example:

$('.rating').rating({
    ...

    callback: function(value){ 
        $.ajax({
            type: "POST",
            url: ...
            data: {rating: value},
            success: function(data){
                $('.rating').rating('select', 1);
            }
        });
    } 
});

I assume that this infinite loop occurs because the callback starts after manual selection. When a user submits their rating, I would like to “choose” the average rating for all users (this is the value in the data returned to the success handler).

How can I do this without starting an infinite loop?

+3
source share
1 answer

They have terrible documentation.

, , "select" wantCallBack. false:

$('.rating').rating('select', 1, false);
+5

Source: https://habr.com/ru/post/1783987/


All Articles