38771

IE8 knockout error - Unable to process binding

Question:

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.

Answer1:

Investigate the exact result that gets returned from your computed.

According to the following:

<a href="https://github.com/knockout/knockout/issues/525" rel="nofollow">https://github.com/knockout/knockout/issues/525</a>

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

Recommend

  • Knockout custom binding handler
  • Repository Browser Only - \"Repository moved permanently to… please relocate”
  • CSS bleed-through with cfinput type=“datefield”
  • Group list of tuples by item
  • Cannot upload to OneDrive using the new SDK
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • FileReader+canvas image loading problem
  • Lost migrations and Azure database is now out of sync
  • Get one-time binding to work for ng-if
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Insert into database using onclick function
  • Dynamically accessing properties of knockoutjs observable array
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Deselecting radio buttons while keeping the View Model in synch
  • jQuery show() function is not executed in Safari if submit handler returns true
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Sony Xperia Z Tablet not found by adb
  • How to recover from a Spring Social ExpiredAuthorizationException
  • How can I estimate amount of memory left with calling System.gc()?
  • Compare two NSDates in iPhone
  • How to get icons for entities from eclipse?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • Hits per day in Google Big Query
  • How to stop GridView from loading again when I press back button?
  • How to get Windows thread pool to call class member function?
  • JaxB to read class hierarchy
  • Is there any way to bind data to data.frame by some index?
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal