Skip to content

Instantly share code, notes, and snippets.

@joshvermaire
Created June 16, 2012 23:16
Show Gist options
  • Save joshvermaire/2942810 to your computer and use it in GitHub Desktop.
Save joshvermaire/2942810 to your computer and use it in GitHub Desktop.
multiple collections per model instance
tlmodel = (attributes, options) ->
attributes = _.extend({}, defaults, attributes) if defaults = getValue(this, "defaults")
attributes or = {}
options or = {}
attributes = @parse(attributes) if options.parse
@collections = {}
@attributes = {}
@_escapedAttributes = {}
@cid = _.uniqueId("c")
@changed = {}
@_silent = {}
@_pending = {}
collection = options.collection
@collections[collection.label] = collection if collection
@set attributes, silent: true
@changed = {}
@_silent = {}
@_pending = {}
@_previousAttributes = _.clone(@attributes)
@initialize.apply this, arguments
window.TLModel = Backbone.Model.extend
constructor: tlmodel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment