-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reverseRelation Collection is always instanceof Backbone.Collection #536
Comments
The problem seems to be hardcoded collectionType: Backbone.Collection
|
Adding test scenario into Backbone-relational test suite: https://rawgit.com/mauron85/Backbone-relational/issue-536/test/index.html |
do this: relations:[{
type: Backbone.HasOne,
key: 'user',
relatedModel: User,
includeInJSON: 'id', //serialize only id not a full object
reverseRelation: {
key: 'routes',
includeInJSON: 'id',
**type: Backbone.HasOne** <-----
}
}]
|
Thank you. But my reverseRelation is HasMany. Or in words User can have many Routes. |
Ah sorry, seemed I misunderstood the problem. Why haven't you used the option |
Thank you. That solved my problem. Actually I thought I have tried to use collectionType some time before. http://jsfiddle.net/mauron85/8uhvyq9L/12/ I'll leave this issue open. Because i think, following notice should be mentioned in the docs somewhere: _"Reverse relation collection DOES NOT inherit it's collection type from relation it is reverse to. If you use reverseRelation, please make sure, you also specify collectionType. If you don't provide it, reverse collection type will be Backbone.Collection"_ And also my examples, might be helpful: |
Description: reverseRelation Collection is always instanceof Backbone.Collection
Expected: reverseRelation Collection is instanceof Routes
Actual: reverseRelation Collection is instanceof Backbone.Collection only
How to reproduce:
jsFiddle example: http://jsfiddle.net/mauron85/8uhvyq9L/
Modified version with model collection as constructor option throws:Uncaught TypeError: collection.on is not a function
jsFiddle: http://jsfiddle.net/mauron85/8uhvyq9L/4/The text was updated successfully, but these errors were encountered: