У меня есть следующий код (также в jsfiddle ):
<table>
<thead><tr><th>Equation</th><th>Equation</th></tr></thead>
<tbody data-bind="template: {name: 'equationTemplate', foreach: equations}"></tbody>
</table>
<script language="javascript" type="text/javascript">
</script>
<script type="text/x-jquery-tmpl" id='equationTemplate'>
<!-- In here I want to be able to break it up into two
columns of two rather than one column of four-->
<tr>
<td>${first}+${second}=<input data-bind="value: answer"/></td>
</tr>
</script>
С этим JS:
$(document).ready(function () {
var viewModel = {
equations: ko.observableArray([
{ first: 1, second: 2, answer: 3 },
{ first: 4, second: 4, answer: 8 },
{ first: 10, second: 10, answer: 20 },
{ first: 5, second: 5, answer: 10}])
};
ko.applyBindings(viewModel);
});
Как мне изменить шаблон навывести это в таблицу из двух строк и двух столбцов?Уравнения 10 + 10 = 20 и 5 + 5 = 10. должны появиться во втором столбце.
Любая помощь с благодарностью.