Skip to content

Instantly share code, notes, and snippets.

@davidguttman
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidguttman/8794970 to your computer and use it in GitHub Desktop.
Save davidguttman/8794970 to your computer and use it in GitHub Desktop.
Backbone style view using Bean for events
bean = require 'bean'
template = require './template.jade'
View = module.exports = (@opts={}) ->
@el = document.createElement 'div'
@setEvents()
@render()
return this
View::setEvents = ->
events = [
['click', '.box', @boxClick]
]
for event in events
[type, selector, handler] = event
bean.on @el, type, selector, handler.bind this
View::render = ->
@el.innerHTML = template()
return this
View::boxClick = (evt) -> # box clicked
@dstokes
Copy link

dstokes commented Feb 4, 2014

y u no Class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment