jquery-bar-rating
jquery-bar-rating copied to clipboard
InitialRating for multiple select elements with same id or class
Hey guys... Looking for a way to add initialRating via data-current-rating having a list of multiple select elements....
$(".rating").barrating({
theme: 'fontawesome-stars-o',
initialRating: $(this).attr('data-current-rating') // does not work
});
This does not work ...
This definitely won't work as you expect as this
may be something else, based on from where you initialise plugin.
Safe would be to loop through all .rating
and apply barrating.
$('.rating').each(function(index, el) {
var $El = $(el);
$El.barrating({
theme: 'fontawesome-stars-o',
initialRating: $El.attr('data-current-rating')
});
});
@ChetanGoti How do you apply this in the HTML or EJS files please? What do you need to pass in the function? It's only outputting the numbers and not the stars.