Skip to content

Instantly share code, notes, and snippets.

@bloudermilk
Last active October 12, 2015 14:48
Show Gist options
  • Save bloudermilk/4043063 to your computer and use it in GitHub Desktop.
Save bloudermilk/4043063 to your computer and use it in GitHub Desktop.
Easy backbone view module bootloading
Backbone.View.register = (role) ->
$ => new @(el: element).render() for element in $("@" + role)
# On page ready, any elements with the role "my-rad-view" will have a
# corresponding MyRadView object instantiated
class MyRadView extends Backbone.View
@register "my-rad-view"
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment