我认为这可能更多是语言问题而不是框架问题,但这里有:
我无法设置复选框的初始值。
我添加了一个jsFiddle
谢谢!
这是麻烦的代码:
var allPrices = [
{ month: 'January', prices: [ (3, true), (4, false), (4, false), (4, false)] },
{ month: 'February', prices: [(3, true), (4, false), (4, false), (4, false)] },
{ month: 'March', prices: [(3, true), (4, false), (4, false), (4, false)] }
]
//--Page ViewModel
var id = 1;
//--Set the structure for the basic price object
function Price(quote, isChecked) {
this.quote = ko.observable(quote);
this.valid = true;
if (isNaN(quote)) {
this.valid = false;
}
this.selected = ko.observable(isChecked);
this.id = id;
id++;
}