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

InitialRating for multiple select elements with same id or class

Open Nick513 opened this issue 7 years ago • 2 comments

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 ...

Nick513 avatar Nov 11 '17 20:11 Nick513

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 avatar Nov 22 '17 13:11 ChetanGoti

@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.

danielvlla avatar May 07 '18 11:05 danielvlla