jquery-bar-rating
jquery-bar-rating copied to clipboard
Update select with new value
I have a question. If a user gives a rating, I want the select (the stars) to auto update with the new value.
My code is as follows:
`$(function () { // var currentRating = $('#DlRating').data('current-rating'); var hidId = $('#hidId').val(); var LblAantalStemmen = $('#LblAantalStemmen').val(); var LblWaardering = $('#LblWaardering').html();
$('#DlRating').barrating({
theme: 'fontawesome-stars-o',
initialRating: LblWaardering,
onSelect: function (value, text, event) {
// rating was selected by a user
if (typeof (event) !== 'undefined') {
$.ajax({
type: 'POST',
url: "/Handlers/handle.ashx",
data: { method: "Waarder", id: hidId, waardering: value },
dataType: "json",
success: function (data) {
//// **HOW CAN I UPDATE BARRATING WITH NEW VALUE data.Waardering**?
// Update labels
$('#LblWaardering').html(data.Waardering);
$('#LblAantalStemmen').html(data.Stemmen);
console.log(data.Waardering);
}
});
}
}
});
});`
Try destroy and re-init it.