Skip to content

Commit

Permalink
Hmm, fix spaces/tabs mix in the example
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulUithol committed Jan 16, 2014
1 parent 80235b9 commit 9bded76
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions backbone-relational.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@
* Example:
*
Zoo = Backbone.RelationalModel.extend( {
relations: [ {
type: Backbone.HasMany,
key: 'animals',
relatedModel: 'Animal',
reverseRelation: {
key: 'livesIn',
includeInJSON: 'id'
// 'relatedModel' is automatically set to 'Zoo'; the 'relationType' to 'HasOne'.
}
} ],
toString: function() {
return this.get( 'name' );
}
relations: [ {
type: Backbone.HasMany,
key: 'animals',
relatedModel: 'Animal',
reverseRelation: {
key: 'livesIn',
includeInJSON: 'id'
// 'relatedModel' is automatically set to 'Zoo'; the 'relationType' to 'HasOne'.
}
} ],
toString: function() {
return this.get( 'name' );
}
} );
Animal = Backbone.RelationalModel.extend( {
toString: function() {
return this.get( 'species' );
}
toString: function() {
return this.get( 'species' );
}
} );
// Creating the zoo will give it a collection with one animal in it: the monkey.
// The animal created after that has a relation `livesIn` that points to the zoo it's currently associated with.
// If you instantiate (or fetch) the zebra later, it will automatically be added.
var zoo = new Zoo( {
name: 'Artis',
animals: [ { id: 'monkey-1', species: 'Chimp' }, 'lion-1', 'zebra-1' ]
name: 'Artis',
animals: [ { id: 'monkey-1', species: 'Chimp' }, 'lion-1', 'zebra-1' ]
} );
var lion = new Animal( { id: 'lion-1', species: 'Lion' } ),
monkey = zoo.get( 'animals' ).first(),
sameZoo = lion.get( 'livesIn' );
monkey = zoo.get( 'animals' ).first(),
sameZoo = lion.get( 'livesIn' );
*/
( function( undefined ) {
"use strict";
Expand Down

0 comments on commit 9bded76

Please sign in to comment.