Created
September 22, 2008 06:44
-
-
Save geoffreyd/11953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
@property | |
This is the actual array of records in the current collection. This | |
property will change anytime the record members change (but not when | |
the member record properties change). | |
@type {Array} | |
*/ | |
records: function() { | |
if ( !this._isAwake ) this.awake(); | |
if (this._changedRecords) this._flushChangedRecords() ; | |
return this._records ; | |
}.property(), | |
/** | |
@private | |
*/ | |
_isAwake: false, | |
// ........................................ | |
// ACTIONS | |
// | |
/** | |
Call this to force the list to refresh. The refresh may not happen | |
right away, depending on the dataSource. | |
*/ | |
refresh: function(options) { | |
if (!this._isAwake) return this.awake(); | |
else this.dataSource.refreshRecords(this.get('records')); | |
}, | |
awake: function(options) { | |
var recordType = this.get('recordType') || SC.Record ; | |
// start awake | |
if (!this.dataSource) throw "collection does not have dataSource" ; | |
this.beginPropertyChanges(); | |
if (!this.isLoading) this.set('isLoading',true) ; | |
this._refreshing = true ; | |
var order = this.get('orderBy') ; | |
if (order && !(order instanceof Array)) order = [order] ; | |
if (!options) options = {} ; | |
options.offset = (this._limit > 0) ? this._offset : 0 ; | |
options.limit = this._limit ; | |
options.conditions = this.get('conditions') ; | |
options.order = order ; | |
options._onSuccess = this._refreshDidComplete.bind(this) ; | |
options._onFailure = options._onSuccess ; | |
options.cacheCode = this._cacheCode ; | |
this.dataSource.listFor(recordType, options) ; | |
this.endPropertyChanges() ; | |
this._isAwake = true ; | |
return this; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment