Last active
August 29, 2015 13:56
-
-
Save davidguttman/8794970 to your computer and use it in GitHub Desktop.
Backbone style view using Bean for events
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
y u no
Class
?