jquery - Set a class or not depending of the item index -
i'm rendering table jquery-tmpl, , don't how pyjama. want set class "shadowed" items index%2==0
.
i'm trying with code, apparently have little mess 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 call:
$.getjson('@url.action("getphotoaudit","photos")/' + id, function (jsondata) { $('#thecommenttemplate').tmpl(jsondata, { dataarrayindex: function (item) { return $.inarray(item, jsondata); } } ).appendto("#audit tbody"); });
what correct syntax?
do have within template code?
can not use :odd
or :even
psuedoclass selectors add class.
for example:
$("#mytable>tbody>tr:even").addclass("shadowed");
Comments
Post a Comment