From 5a4f31b432a56c4278b606ac178a770416cad3eb Mon Sep 17 00:00:00 2001 From: Paul Roth Date: Thu, 10 May 2012 16:46:01 -0500 Subject: [PATCH 1/4] UPDATE: add in a queryMore function to the forcetk to allow simpler handling of the rest pagination urls. Calling forcetkClient.ajax doesn't quite work as ajax adds on 'services/data' to the request, which is already present from successResponse.nextRecordsUrl. Signed-off-by: Paul Roth --- forcetk.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/forcetk.js b/forcetk.js index f754db9..2838e68 100644 --- a/forcetk.js +++ b/forcetk.js @@ -430,6 +430,31 @@ if (forcetk.Client === undefined) { this.ajax('/' + this.apiVersion + '/query?q=' + escape(soql) , callback, error); } + + /* + * Queries the next set of records based on pagination. + *

This should be used if performing a query that retrieves more than can be returned + * in accordance with http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_query.htm

+ *

Ex: forcetkClient.queryMore( successResponse.nextRecordsUrl, successHandler, failureHandler )

+ * + * @param url - the url retrieved from nextRecordsUrl or prevRecordsUrl + * @param callback function to which response will be passed + * @param [error=null] function to which jqXHR will be passed in case of error + */ + forcetk.Client.prototype.queryMore = function( url, callback, error ){ + + //-- ajax call adds on services/data to the url call, so only send the url after + var serviceData = "services/data"; + var index = url.indexOf( serviceData ); + + if( index > -1 ){ + url = url.substr( index + serviceData.length ); + } else { + //-- leave alone + } + + this.ajax( url, callback, error ); + } /* * Executes the specified SOSL search. From 26285e40a9c86c6867182b07d6411099725cc3ee Mon Sep 17 00:00:00 2001 From: Paul Roth Date: Thu, 10 May 2012 16:47:52 -0500 Subject: [PATCH 2/4] Fix the whitespacing to be more inline with the rest of the forcetk toolkit. Signed-off-by: Paul Roth --- forcetk.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/forcetk.js b/forcetk.js index 2838e68..ef02b46 100644 --- a/forcetk.js +++ b/forcetk.js @@ -442,18 +442,17 @@ if (forcetk.Client === undefined) { * @param [error=null] function to which jqXHR will be passed in case of error */ forcetk.Client.prototype.queryMore = function( url, callback, error ){ - - //-- ajax call adds on services/data to the url call, so only send the url after - var serviceData = "services/data"; - var index = url.indexOf( serviceData ); - - if( index > -1 ){ - url = url.substr( index + serviceData.length ); - } else { - //-- leave alone - } - - this.ajax( url, callback, error ); + //-- ajax call adds on services/data to the url call, so only send the url after + var serviceData = "services/data"; + var index = url.indexOf( serviceData ); + + if( index > -1 ){ + url = url.substr( index + serviceData.length ); + } else { + //-- leave alone + } + + this.ajax( url, callback, error ); } /* From e83eb3296825a6795eb1f2761e0b31d169432522 Mon Sep 17 00:00:00 2001 From: Paul Roth Date: Thu, 10 May 2012 16:49:16 -0500 Subject: [PATCH 3/4] cleanup: also adjust the whitespacing in the doc comments. Signed-off-by: Paul Roth --- forcetk.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/forcetk.js b/forcetk.js index ef02b46..550df93 100644 --- a/forcetk.js +++ b/forcetk.js @@ -432,13 +432,13 @@ if (forcetk.Client === undefined) { } /* - * Queries the next set of records based on pagination. - *

This should be used if performing a query that retrieves more than can be returned - * in accordance with http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_query.htm

- *

Ex: forcetkClient.queryMore( successResponse.nextRecordsUrl, successHandler, failureHandler )

- * - * @param url - the url retrieved from nextRecordsUrl or prevRecordsUrl - * @param callback function to which response will be passed + * Queries the next set of records based on pagination. + *

This should be used if performing a query that retrieves more than can be returned + * in accordance with http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_query.htm

+ *

Ex: forcetkClient.queryMore( successResponse.nextRecordsUrl, successHandler, failureHandler )

+ * + * @param url - the url retrieved from nextRecordsUrl or prevRecordsUrl + * @param callback function to which response will be passed * @param [error=null] function to which jqXHR will be passed in case of error */ forcetk.Client.prototype.queryMore = function( url, callback, error ){ From 329cde434aa4a0cae4a5a11bf7ace45ee8df47c4 Mon Sep 17 00:00:00 2001 From: Paul Roth Date: Thu, 10 May 2012 16:50:58 -0500 Subject: [PATCH 4/4] also remove tabs on the initial doc comment Signed-off-by: Paul Roth --- forcetk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forcetk.js b/forcetk.js index 550df93..80ea067 100644 --- a/forcetk.js +++ b/forcetk.js @@ -431,7 +431,7 @@ if (forcetk.Client === undefined) { , callback, error); } - /* + /* * Queries the next set of records based on pagination. *

This should be used if performing a query that retrieves more than can be returned * in accordance with http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_query.htm