Skip to content

Instantly share code, notes, and snippets.

@erichocean
Created September 23, 2008 02:35
Show Gist options
  • Save erichocean/12208 to your computer and use it in GitHub Desktop.
Save erichocean/12208 to your computer and use it in GitHub Desktop.
/**
Call this to force the list to refresh. The refresh may not happen
right away, depending on the dataSource.
*/
refresh: function() {
var recordType = this.get('recordType') || SC.Record ;
var offset = (this._limit > 0) ? this._offset : 0 ;
if (!this._boundRefreshFunc) {
this._boundRefreshFunc = this._refreshDidComplete.bind(this) ;
}
// start refresh
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] ;
this.dataSource.listFor({
recordType: recordType,
offset: offset,
limit: this._limit,
conditions: this.get('conditions'),
order: order,
callback: this._boundRefreshFunc,
cacheCode: this._cacheCode
}) ;
this.endPropertyChanges() ;
return this;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment