jquery-bar-rating icon indicating copy to clipboard operation
jquery-bar-rating copied to clipboard

Update select with new value

Open NiekRood opened this issue 7 years ago • 1 comments

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);
                }
            });
        }
    }
});

});`

NiekRood avatar Sep 01 '17 16:09 NiekRood

Try destroy and re-init it.

dummlutz avatar Apr 12 '18 04:04 dummlutz