awesome-rating
awesome-rating copied to clipboard
Applying decimals
I am trying to apply a decimal rating i.e. 2.3 but it won't display the correct result. I'm using knockout.js. Any ideas how to fix?
var rating = ko.observable(2.3); var options = { values: [1,2,3,4,5], allowFractional: true, calculateFractional: function (current, rate) { if (current.indexOf(rate) === 1) { return 0.6 }; return 1; }, allowFractional: true, readonly: true, applyHoverCss: false }
I did this which works but how would you apply decimals without my edit? calculateFractional: function (current, rate) { if (current - rate > 1) { return 1; } else { var x = current - rate; return 1 + x; } },