我尝试在<select>
控件上使用模板,但它不起作用。这是不起作用的代码。
<select data-bind="template: { name: 'os-template-detail', foreach: operatingSystems },
value: selectedOperatingSystem"></select>
但是当我使用普通绑定时,效果很好。
<select data-bind="options: operatingSystems,
optionsText: function (item) {
return item.Name
},
value: selectedOperatingSystem"></select>
所以,我想知道我做错了什么,或者只是框架的限制。
更新 它们都显示了操作系统列表。问题是,当我在第一个组合框上选择一个操作系统时,它不会更新它的来源,而第二个cobobox会更新它的来源。
答案 0 :(得分:0)
我认为您错过了指定operatingSystems
列表和os-template-detail
应如何组成option
元素的方式。绑定问题是,淘汰赛会尝试列出<select>
代码而不是option
代码。
这可能有效:
<select data-bind="foreach: operatingSystems">
<option data-bind="template: {name: 'os-template-detail', data: $data}">
</select>
我还建议使用Durandal
的合成而不是挖空模板。 This link描述了如何将淘汰赛与durandal整合。