Created
January 6, 2012 14:20
-
-
Save timruffles/1570806 to your computer and use it in GitHub Desktop.
Simple list viewmodel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ListView = (el) -> | |
| views = [] | |
| ["pop","shift"].each (method) => | |
| @[method] = -> | |
| remove = views[method]() | |
| el.removeChild remove.el | |
| [["unshift","prepend"],["push","append"]].each ([array,dom]) => | |
| @[array] = (view) -> | |
| views[array](view) | |
| byModelId[view.model.id] = view | |
| $(el)[dom](view.el) | |
| @size = -> | |
| views.length | |
| this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment