Skip to content

Instantly share code, notes, and snippets.

@amundo
Created September 30, 2012 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amundo/3808753 to your computer and use it in GitHub Desktop.
Save amundo/3808753 to your computer and use it in GitHub Desktop.
wondering about top-level persistence of a netsted object in backbone
TextCollection = Backbone.Collection.extend({
model: Text,
localStorage: new Backbone.LocalStorage('textCollection') // i only want to persist here
})
Text = Backbone.Model.extend({
initialize: function(options){
this.set('sentenceCollection', new SentenceCollection())
}
})
Sentence = Backbone.Model.extend({})
SentenceCollection = Backbone.Collection.extend({
model: Sentence,
// I don't want a url or localStorage here, I just want to hand it up to the text
// should i override Sentence.save? how?
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment