这是我的模板:Knockoutjs没有更新我的UI时,我改变observableArray
<tr>
<td>
<table>
<thead>
<th>
<span>Option name:</span>
</th>
</thead>
<tbody data-bind="template: {name: 'optionChoiceTemplate', foreach: choices, templateOptions:{choiceArray: choices} }"></tbody>
</table>
<button data-bind="click: function(){choices.push('');}">Add new</button>
</td>
</tr>
但是,当我点击“新增”按钮,我的观点不更新,以包括与新选项空的字符串。我已经检查过调试器,将空字符串添加到选项中,并且我确定选择是observableArray,还有什么可能会出错?
谢谢。很可能后面会有一些与该文本关联的其他数据,所以我会将它变成一个对象。 – Drew 2012-01-03 05:13:10