Skip to content

Instantly share code, notes, and snippets.

@collin
Created April 5, 2011 03:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collin/902979 to your computer and use it in GitHub Desktop.
Save collin/902979 to your computer and use it in GitHub Desktop.
_.extend Backbone.View::
tagName: "div"
initialize: (@model = new Backbone.Model, @el = @build_element()) -> @delegateEvents()
# :api:private
klass_string: (parts=[]) ->
if @constructor is Backbone.View
parts.push "BackboneView"
".#{parts.join '.'}"
else
parts.push @constructor.name
@constructor.__super__.klass_string parts
element_string: () ->
base = "#{@tagName}.#{@klass_string()}"
if @model and @model.cid
base += "##{@model.cid}"
if @model and @model.constructor
base += ".#{@model.constructor.name}"
base
build_element: () ->
$.satisfy @element_string()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment