次の点を考慮してください。
<div data-bind="with: QuoteSelectedViewModel">
selected quote is : <span data-bind="text: ProductName"></span>
<!-- ko foreach: CoverQuotesViewModel -->
<br/>
<input type="checkbox" data-bind="checked: IsSelected"></input>
<input type="text" data-bind="value: Label, enable: IsSelected"></input>
<!-- /ko -->
</div>
QuoteSelectedViewModel は次のとおりです。
{
"ProductName": "Perfect",
"MonthPrice": 0,
"QuarterPrice": 0,
"BiannualPrice": 0,
"YearPrice": 0,
"CoverQuotesViewModel": [ {
"ProductName": "Select",
"Label": "Première Assistance 24h/24 (GRATUITE)",
"IsVisible": true,
"IsMandatory": true,
"IsSelected": false,
"IsChoice": false,
"IsComposite": false,
"YearPrice": "451451",
"BiannualPrice": 0.49,
"QuarterPrice": 0.2475,
"MonthPrice": 0.08333333333333333,
"Childs": [],
"SelectedCoverQuote": null
},
{
"ProductName": "Select",
"Label": "Assistance PLUS 24h/24",
"IsVisible": true,
"IsMandatory": false,
"IsSelected": true,
"IsChoice": false,
"IsComposite": false,
"YearPrice": 36.0646,
"BiannualPrice": 18.2182,
"QuarterPrice": 9.20205,
"MonthPrice": 3.098333333333333,
"Childs": [],
"SelectedCoverQuote": null
}]
}
jsfiddle のコードを参照してください: http://jsfiddle.net/graphicsxp/j8HdW/4/
問題は、チェックボックスをオンまたはオフにしてもモデルが更新されないため、テキストボックスが更新されないことです。
デモを機能させるには、まず「見積もりを取得」ボタンをクリックしてから、「見積もりを選択」ボタンをクリックします。
何が問題なのですか?
編集
わかりました、jsfiddle は非常に複雑だったので、簡略化したバージョンを次に示します: http://jsfiddle.net/graphicsxp/WCA5f/