Created
April 29, 2009 15:38
-
-
Save ttdonovan/103848 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
| fetchRecords: function(store, fetchKey, params) { | |
| var ret = [], idx, len, id, recordType, rec, url, request, datasource ; | |
| datasource = this ; | |
| len = params.length ; | |
| for(idx = 0; idx < len; idx++) { | |
| storeKey = params[idx] ; // storeKey | |
| id = store.idFor(storeKey) ; // record id | |
| recordType = store.recordTypeFor(storeKey) ; | |
| rec = store.find(recordType, id) ; // specific record found by id | |
| url = rec.get('resourceURL') ; // resource url | |
| ret.push(storeKey) ; // return array of storeKeys | |
| request = SC.Request.getUrl(url) ; | |
| request.set('isJSON', YES) ; | |
| request.addObserver('response', function(r) { datasource.fetchRecordsDidComplete(r, store, storeKey)}) ; | |
| request.send() ; | |
| } | |
| return ret; // return array of storeKeys | |
| }, | |
| fetchRecordsDidComplete: function(r, store, storeKey) { | |
| var response ; | |
| response = r.response() ; | |
| store.dataSourceDidComplete(storeKey, response) ; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment