Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying decimals #5

Open
AlwaysVbNet opened this issue Apr 10, 2018 · 0 comments
Open

Applying decimals #5

AlwaysVbNet opened this issue Apr 10, 2018 · 0 comments

Comments

@AlwaysVbNet
Copy link

AlwaysVbNet commented Apr 10, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant