I'm rendering a table with jquery-tmpl, and I don't get how to do a pyjama. Basically what I want is set the class "shadowed" to the items with a index%2==0
.
I'm trying with this code, but apparently I have a little mess with the jquery-tmpl syntax:
<script id="theCommentTemplate" type="text/x-jquery-tmpl">
<tr {{if ${$item.dataArrayIndex($item.data)} %2==0 }}
class="shadowed"
{{/if}}><td>${Reviewer}</td><td>${Date}</td><td>${StatusFrom}</td><td>${StatusTo}</td><td>${Comments}</td></tr>
</script>
And this is the call:
$.getJSON('@Url.Action("GetPhotoAudit","Photos")/' + id, function (jsonData) {
$('#theCommentTemplate').tmpl(jsonData,
{
dataArrayIndex: function (item) {
return $.inArray(item, jsonData);
}
}
).appendTo("#audit tbody");
});
What would be the correct syntax?