這是我的模板: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