Skip to content

Applying decimals #5

@AlwaysVbNet

Description

@AlwaysVbNet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions