Binding 具有enable属性的敲除绑定问题
考虑以下几点:Binding 具有enable属性的敲除绑定问题,binding,knockout.js,Binding,Knockout.js,考虑以下几点: <div data-bind="with: QuoteSelectedViewModel"> selected quote is : <span data-bind="text: ProductName"></span> <!-- ko foreach: CoverQuotesViewModel --> <br/> <input type="checkbox" data-bind="checked
<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>
请参阅JSFIDLE上的代码:
问题是,选中和取消选中复选框不会更新模型,因此不会更新文本框
要使演示正常工作,请首先单击“获取报价”按钮,然后单击“选择报价”按钮
知道怎么了吗
编辑
好的,由于JSFIDLE过于复杂,这里有一个简化的版本:您的
IsSelected
不是可观察的-您的示例代码至少包含100个与IsSelected
无关的属性,只是添加了一些杂音。请把你的例子减少到能证明你的问题的最小案例!您的小提琴正在使用github的资源。这些不起作用。转到并找到一个供您的资源使用的链接。我已经用cdnjs的资源更新了演示:我不认为这是问题所在。是的,viewModel相当大,但它已经比我的产品viewModel小了。我希望它和原来的一样接近。我只使用相关属性更新了JSFIDLE。你能帮忙吗?
{
"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
}]
}