-
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
previous #101
Comments
Hmm, yes. Seems like the Backbone.Model constructor just takes the plain By the way, for collections/HasMany relations this wouldn't really do much. |
Can't really seem to get this to surface. I don't know if the use of a collection or the fetching is a factor here, but using var User = Backbone.RelationalModel.extend(
toString: function() {
return this.get( 'username' );
}
);
var Person = Backbone.RelationalModel.extend({
relations: [{
type: Backbone.HasOne,
key: 'user',
relatedModel: User
}]
});
var PersonCollection = Backbone.Collection.extend({
model: Person
});
var coll = new PersonCollection();
var user = new User( { id: 3, username: 'root' } );
coll.reset( [ { id: 2, user: 3 } ] );
var person = coll.at( 0 );
console.log( person.get( 'user' ), person.previous( 'user' ) );
// prints "root root" |
Ok I think my problem is that the document I fetch looks something like that if use person / user relation example
|
Well apparently is linked to issue #91 my relation was not initialized correctly |
Just noticed this little bug
first time you fetch a collection
model.previous('some-relation') will give you a string id
following change will return the related object. It would be good to always return either the id or the model, don't you think ?
The text was updated successfully, but these errors were encountered: