Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not set the selected property. unspecified error. knockoutJs

I'm using VS2010 on windows XP, Jquery-1.7.1.min.js, knockout-2.1.0.js, my browser is IE8. trying to make a simple biding with array and :

here is the code:

//my.js:
$(function () {
   function tvm() {
     // Array
     this.tickets = [
        { name: 'A', price: 125 },
        { name: 'B', price: 128 },
        { name: 'C', price: 145 }
     ];
     // this will hold the selected value
     this.chosenTicket = ko.observable();
   }
   ko.applyBindings(new tvm());
});

//html:
<select
   data-bind="options: tickets,
          optionsCaption:'choose...',
          optionsText: 'name',
          value: chosenTicket">
</select>

<p data-bind="with: chosenTicket">
   <b data-bind="text: name"></b>
   <b data-bind="text: price"></b>
</p>

when running this I can see the select element with its data(until now everything good), when try to select a value from the select element I get the following error message: "Could not set the selected property. unspecified error"

Any idea how to fix this problem?(couldn't find help on the forums),

like image 264
MRK Avatar asked Nov 25 '12 07:11

MRK


1 Answers

Check the jsFiddle for the same http://jsfiddle.net/rupesh_kokal/wPzNQ/

The code what you have written works fine with the latest from knockout js.

You might want to cross-check the version of jsFiddle once.

like image 186
Rups Avatar answered Oct 02 '22 02:10

Rups