Skip to content

Instantly share code, notes, and snippets.

@JeremySkinner
Created February 24, 2011 10:25
Show Gist options
  • Save JeremySkinner/842026 to your computer and use it in GitHub Desktop.
Save JeremySkinner/842026 to your computer and use it in GitHub Desktop.
<table>
<tbody data-bind="template: 'MyTemplate'></tbody>
</table>
<script id="MyTemplate" type="x-jquery-tmpl">
{{each(i, row) Rows}}
<tr>
<td>
<select data-bind="options: row.Options, optionsText: 'Text', optionsValue: 'Value'"></select>
</td>
</tr>
{{/each}}
</script>
<script type="text/javascript">
var viewModel = {}
viewModel.Rows = [
{
Options: [ { Text: 'First', Value: 1}, {Text:'Second', Value: 2} ]
},
{
Options: [...]
}
];
ko.applyBindings(viewModel);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment