vendor/backbone-relational-0.6.0.js
function( collection ) {
			if ( this.related ) {
				this.related
					.unbind( 'relational:add', this.handleAddition )
					.unbind( 'relational:remove', this.handleRemoval )
					.unbind( 'relational:reset', this.handleReset )
			}

			if ( !collection || !( collection instanceof Backbone.Collection ) ) {
				collection = new this.collectionType( [], this._getCollectionOptions() );
			}

			collection.model = this.relatedModel;
			
			if ( this.options.collectionKey ) {
				var key = this.options.collectionKey === true ? this.options.reverseRelation.key : this.options.collectionKey;
				
				if ( collection[ key ] && collection[ key ] !== this.instance ) {
					if ( Backbone.Relational.showWarnings && typeof console !== 'undefined' ) {
						console.warn( 'Relation=%o; collectionKey=%s already exists on collection=%o', this, key, this.options.collectionKey );
					}
				}
				else if ( key ) {
					collection[ key ] = this.instance;
				}
			}
			
			collection
				.bind( 'relational:add', this.handleAddition )
				.bind( 'relational:remove', this.handleRemoval )
				.bind( 'relational:reset', this.handleReset );
			
			return collection;
		}
function( collection ) {
			if ( this.related ) {
				this.related
					.unbind( 'relational:add', this.handleAddition )
					.unbind( 'relational:remove', this.handleRemoval )
					.unbind( 'relational:reset', this.handleReset )
			}

			if ( !collection || !( collection instanceof Backbone.Collection ) ) {
				collection = new this.collectionType( [], this._getCollectionOptions() );
			}

			collection.model = this.relatedModel;
			
			if ( this.options.collectionKey ) {
				var key = this.options.collectionKey === true ? this.options.reverseRelation.key : this.options.collectionKey;
				
				if ( collection[ key ] && collection[ key ] !== this.instance ) {
					if ( Backbone.Relational.showWarnings && typeof console !== 'undefined' ) {
						console.warn( 'Relation=%o; collectionKey=%s already exists on collection=%o', this, key, this.options.collectionKey );
					}
				}
				else if ( key ) {
					collection[ key ] = this.instance;
				}
			}
			
			collection
				.bind( 'relational:add', this.handleAddition )
				.bind( 'relational:remove', this.handleRemoval )
				.bind( 'relational:reset', this.handleReset );
			
			return collection;
		}
function ( collection ) { if ( this . related ) { this . related . unbind ( 'relational:add' , this . handleAddition ) . unbind ( 'relational:remove' , this . handleRemoval ) . unbind ( 'relational:reset' , this . handleReset ) } if ( ! collection || ! ( collection instanceof Backbone . Collection ) ) { collection = new this . collectionType ( [ ] , this . _getCollectionOptions ( ) ) ; } collection . model = this . relatedModel ; if ( this . options . collectionKey ) { var key = this . options . collectionKey === true ? this . options . reverseRelation . key : this . options . collectionKey ; if ( collection [ key ] && collection [ key ] !== this . instance ) { if ( Backbone . Relational . showWarnings && typeof console !== 'undefined' ) { console . warn ( 'Relation=%o; collectionKey=%s already exists on collection=%o' , this , key , this . options . collectionKey ) ; } } else if ( key ) { collection [ key ] = this . instance ; } } collection . bind ( 'relational:add' , this . handleAddition ) . bind ( 'relational:remove' , this . handleRemoval ) . bind ( 'relational:reset' , this . handleReset ) ; return collection ; }
Bind events and setup collectionKeys for a collection that is to be used as the backing store for a HasMany.
If no 'collection' is supplied, a new collection will be created of the specified 'collectionType' option.
@param {Backbone.Collection} [collection]
Bind events and setup collectionKeys for a collection that is to be used as the backing store for a HasMany . If no collection is supplied a new collection will be created of the specified collectionType option .