Reputation: 1231
I have a viewmodel like this,
var sectorViewModel = function() {
this.currentValue = ko.observable();
this.previousValue = ko.observable();
....
this.maxValue = ko.computed(function() {
return Math.max(this.currentValue(), this.previousValue(), ...);
}, this);
}
ko.applyBinding(sectorVM, document.getElementById("divSector");
And this is the html snippet where I am doing the data-bind,
<div id="divSector">
...
<div class="bar" data-bind="style: {width: (currentValue()*100)/maxValue() + '%'}"></div>
...
</div>
Works fine in all browsers except for IE8. In IE8 I see this error in dev tool -
Invalid argument. Unable to process binding "style: function() {return..."
Any idea how can I get this to work in IE8?
Thanks.
Upvotes: 0
Views: 326
Reputation: 1650
Investigate the exact result that gets returned from your computed.
According to the following:
https://github.com/knockout/knockout/issues/525
The newer browsers probably handle a result such as xx.asmanydecimalplacesrequired% but may not be compatible with IE8. You should make sure the returned value is a compatible width style property for IE8 - e.g. trim it to 2 decimal places - that's the first thing I would try.
Let me know if this helps, because I'm totally figuring this out via research, and don't forget to vote up if that's the case ;P
Upvotes: 1