Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (22 sloc) 711 Bytes
title slug category tags
Dealing with slow backbone-relational models cloning
dealing-with-slow-backbone-relational-models-cloning
web
web, backbonejs, coffeescript

Be careful when working with backbone-relational and cloning elements.

If you do clone elements using toJSON method, be sure to specify includeInJSON: false in the model definition, eg.

relations: [
  {
    type: Backbone.HasOne
    key: 'fieldInstance'
    relatedModel: 'App.M.FieldInstance'
    reverseRelation:
      includeInJSON: false
      type: Backbone.HasOne
      key: 'fieldInstanceImage'
  }
]

Otherwise, you'll end up with a heckload of objects and the app will be unusable with 5+ cloned models.