Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implement list.js tag helper

  • Loading branch information...
commit 3fe66ee4e28407abb4f29bcef20f22914b570b5c 1 parent 21c7233
@marcuswestin authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 list.js
View
13 list.js
@@ -0,0 +1,13 @@
+module.exports = function list(items, onSelect, render) {
+ return div('list', function(tag) {
+ var data = { id:0 }
+ tag.append(map(items, function(item) {
+ var id = data.id++
+ data[id] = item
+ return div('list-item', { listId:id }, render(item))
+ }))
+ $(tag).on('mousedown', '.list-item', function(event) {
+ onSelect(data[$(this).attr('listId')])
+ })
+ })
+}
Please sign in to comment.
Something went wrong with that request. Please try again.