Skip to content

Instantly share code, notes, and snippets.

@mrrooijen
Created October 28, 2012 11:41
Show Gist options
  • Save mrrooijen/3968395 to your computer and use it in GitHub Desktop.
Save mrrooijen/3968395 to your computer and use it in GitHub Desktop.
Batman.js Even/Odd CSS trick for iterations.
Batman.mixin Batman.Filters,
indexOf: (set, iteration) -> set?.toArray().indexOf(iteration)
isEven: (input) -> input % 2 == 0
<ul>
<li data-foreach-task="tasks"
data-bind="task.name"
data-addclass-even="tasks | indexOf task | isEven"></li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment