I am trying to figure out how to create a collection of collections with backbone.js. I'm new to the spine. I have something like the following situation:
+---------------+ +------------------+ | Playlists | | Playlist | |---------------| 0..* |------------------| | +-------------->| Name | | | | | | | | | +---------------+ +-------+----------+ | | |0..* v +------------------+ | Track | |------------------| | Name | | Artist | | | +------------------+
In code, it looks something like this:
var trackModel = Backbone.Model.extend({
However, I always get an error in the js console:
Uncaught TypeError: Object [object Object] has no method '_validate'
when I try to execute a function that starts validation (e.g. add, fetch, ...)
It doesn't matter if _validate add a validate or _validate to any of the collections or models.
I believe this is because backbone.js does not support collections in collections. Is there any other way that works?
UPDATE:
Here's what it looks like right now
var Track = Backbone.Model.extend({ //trackdata }); var Tracks = Backbone.Collection.extend({ model:Track; }); var Playlist = Backbone.Model.extend({ //name : ... tracks: new Tracks () }); var Playlists = Backbone.Collection.extend({ url : "playlists", model : Playlist });
krial Apr 30 '12 at 17:51 2012-04-30 17:51
source share