Is your KnockoutJS ‘options’ binding working on IE11 but not on IE8?

I had this issue, and since I am not a javascript expert, it took me a while to figure this out.

If you are binding to a static array (declared in code) like such:

self.statusOptions = [
        { name: "Option 1", id: 1 },
        { name: "Option 2", id: 2 },
        { name: "Option 3", id: 3 },
    ];

This will go horribly wrong because the that final comma. In IE 8 this means there is another, empty, item in the array. In IE11 this seems to work fine. So change it to this and you are good to go:

self.statusOptions = [
        { name: "Option 1", id: 1 },
        { name: "Option 2", id: 2 },
        { name: "Option 3", id: 3 }
    ];

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.