{"comment":{"created_at":"2011-10-14T07:17:16Z","body":"There's an existing issue about this. The solution Paul settled with was creating an empty Contest model before a Contests collection is created, or otherwise the reverse relation won't be established. I could see better solutions to this, might even submit a patch!","updated_at":"2011-10-14T07:17:16Z","url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/comments/2404074","id":2404074,"user":{"gravatar_id":"7165197598f2429a0a8c15fd3cadb3d8","avatar_url":"https://secure.gravatar.com/avatar/7165197598f2429a0a8c15fd3cadb3d8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/emsten","id":628612,"login":"emsten"}},"action":"created","issue":{"number":41,"created_at":"2011-10-14T02:25:37Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"I have a regular Backbone.Collection called `Contests` and a Backbone.RelationalModel called `Contest` which has the following relation to a collection of `Submission`'s:\r\n\r\n    Contest  = Backbone.RelationalModel.extend\r\n      relations: [{\r\n        type: Backbone.HasMany\r\n        key: '_submissions'\r\n        relatedModel: 'Submission'\r\n        collectionType: 'SubmissionCollection'\r\n        includeInJSON: '_id'\r\n        reverseRelation:\r\n           key: 'contest'\r\n          includeInJSON: '_id'\r\n        }]\r\n      urlRoot: '/api/contests'\r\n      idAttribute: '_id'\r\n\r\nin my app, when I do something like `contests = new Contests(); contests.fetch()` then I get back a collection of `Contest`'s which is fine. However, when I inspect the `Contest` models within this collection, the `_submissions` attribute is an empty array, instead of a `SubmissionCollection`, (i.e. an instance of a BackboneCollection). Therefore I cannot bind events etc to the collection of Submissions. \r\n\r\nI know that Backbone-relational is doing what its supposed to do because when I type in my console `x = new Contest()` and I inspect this model, the '_submissions' attribute is an empty `SubmissionCollection`. \r\n\r\nSo what I want to know is how can I get the same behaviour when I load my Contests as part of a Contest collection.","comments":1,"title":"Getting back empty array when I need an empty Backbone.Collection","updated_at":"2011-10-14T07:17:16Z","url":"https://api.github.com/repos/PaulUithol/Backbone-relational/issues/41","id":1907135,"assignee":null,"milestone":null,"closed_at":null,"user":{"gravatar_id":"9a793827c924cdbde086b4aa8bf9fe05","avatar_url":"https://secure.gravatar.com/avatar/9a793827c924cdbde086b4aa8bf9fe05?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/cjroebuck","id":12208,"login":"cjroebuck"},"html_url":"https://github.com/PaulUithol/Backbone-relational/issues/41","labels":[],"state":"open"},"legacy":{"issue_id":1907135,"comment_id":2404074}}