jQuery-tmpl: Expose array index for items
|Reported by:||serg555||Owned by:|
When you are passing an array of objects to a template, I think $item object should also expose current array index. I saw examples in the repository how to get item index by calling external function with $.inArray(), but that's like the most inconvenient and inefficient method possible, plus wouldn't always work.
Item index is required very often - when you need to check if this is the first item, the last item, for alternating classes.
Full scale templating engines also usually have: count, isFirst, and isLast internal variables, but as long as there is an index you can do the rest yourself.
Change History (7)
comment:1 Changed 7 years ago by
|Priority:||undecided → low|
|Status:||new → closed|