dreyescat / bootstrap-rating

Bootstrap Rating is a jQuery plugin that creates a rating control that uses Bootstrap glyphicons for rating symbols.
http://dreyescat.github.io/bootstrap-rating/
MIT License
192 stars 78 forks source link

add callback after rate #29

Closed rodrigogalura closed 7 years ago

rodrigogalura commented 7 years ago

Add callback and rate argument after the user click or rate.

dreyescat commented 7 years ago

There is already a way to be notified when the rate is changed. The rating control wraps an input where you can just attach your change handler:

$('input').rating().on('change', function () {
  $(this).next('.label').text($(this).val());
});

Check this jsfiddle.

I prefer not using a callback for this kind of notification. I see events more appropriate.

Maybe, as an improvement, we could add a custom event rating.change similar to those thrown on symbol rate enter and leave.

$input.trigger('rating.rate', [rating._indexToRate(fractionalIndex(e))]);

This would allow you to attach as many event handlers as you want like this:

$('.rating').on('rating.rate', function (e, rate) {
  window.alert('Rate: ' + rate);
})
rodrigogalura commented 7 years ago

oh I see 👍, thanks @dreyescat.

But there is one thing, When you put fractions: 2 in the option and you implement tooltip. The rate is not accurate. Check this jsfiddle

dreyescat commented 7 years ago

Check Symbol events section. I think this is what you are looking for. You can see one fractional rating with tooltips in the demo page.