Skip to content

Commit 6514b30

Browse files
author
Pat Patterson
committed
Merge pull request developerforce#16 from paulroth3d/master
Add in queryMore method to the forceTk toolkit
2 parents b7c8f65 + 329cde4 commit 6514b30

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

forcetk.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,30 @@ if (forcetk.Client === undefined) {
430430
this.ajax('/' + this.apiVersion + '/query?q=' + escape(soql)
431431
, callback, error);
432432
}
433+
434+
/*
435+
* Queries the next set of records based on pagination.
436+
* <p>This should be used if performing a query that retrieves more than can be returned
437+
* in accordance with http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_query.htm</p>
438+
* <p>Ex: forcetkClient.queryMore( successResponse.nextRecordsUrl, successHandler, failureHandler )</p>
439+
*
440+
* @param url - the url retrieved from nextRecordsUrl or prevRecordsUrl
441+
* @param callback function to which response will be passed
442+
* @param [error=null] function to which jqXHR will be passed in case of error
443+
*/
444+
forcetk.Client.prototype.queryMore = function( url, callback, error ){
445+
//-- ajax call adds on services/data to the url call, so only send the url after
446+
var serviceData = "services/data";
447+
var index = url.indexOf( serviceData );
448+
449+
if( index > -1 ){
450+
url = url.substr( index + serviceData.length );
451+
} else {
452+
//-- leave alone
453+
}
454+
455+
this.ajax( url, callback, error );
456+
}
433457

434458
/*
435459
* Executes the specified SOSL search.

0 commit comments

Comments
 (0)