Using the most excellent Star Ratings from fyneworks.com (v2.5) - I'd
like to be able to set the current value of a ratings object from an
external function.

We use a callback to post the rating value to an ajax handler, which
then returns the new average rating for that item. E.g. 4 users have
rated an item, average is 4/10. 5th user rates it 9/10, new average is
therefore 5/10.

Here's what I'm coding:
$('div.userRating input').rating({ half: true, callback:
ratingCall });

function ratingCall(value, link) {
        var _productId = this.name.substring(5);// e.g. 'rate-4526' = '4526'
        // post rating (value), userid, productid to handler, returns json
        $.post('/handlers/PostRating.ashx', { **my data, blah** }, function
(data) {
                var _dataObj = eval('('+ data +')');
                var _msg = data.FeedbackMessage;
                $('#ratingMsg-' + _productId).html(_msg).show();
                var _newAvg = data.NewAverage;
                // update this ratings instance with new average - How?
        });
}

I'm setting the initial value when I write out the input elements -
e.g. <input type="radio" name="rate-4526" value="4" checked="checked" /
> - but I'm just not sure where to start with trying to update the
stars ui from the callback function.

Anyone got any ideas? I'm hoping Diego A will catch a glimpse of
this :)

Reply via email to