mreq

…a blog about ubuntu, sublime text and the web

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.