PDA

View Full Version : readRecords fails with empty json objects on iOS



pdm
9 Jul 2012, 3:31 AM
Sencha Touch version tested:

1.1.1
Platform tested against:

iOS 5.x
iOS 5 Simulator
Chrome
Description:

when returning an empty element in json, readRecords in Ext.data.Reader fails
Chrome seems to be tolerant of this, but iOS with phonegap/cordova isn't. Throws

TypeError: 'undefined' is not an object

Fix:

--- a/www/lib/touch/sencha-touch-debug-w-comments.js
+++ b/www/lib/touch/sencha-touch-debug-w-comments.js
@@ -15541,7 +15541,7 @@ Ext.data.Reader = Ext.extend(Object, {
data = this.getData(data);

var root = this.getRoot(data),
- total = root.length,
+ total = root ? root.length : 0,
success = true,
value, records, recordCount;

@@ -15559,7 +15559,7 @@ Ext.data.Reader = Ext.extend(Object, {
}
}

- records = this.extractData(root, true);
+ records = root ? this.extractData(root, true) : [];
recordCount = records.length;

return new Ext.data.ResultSet({

mitchellsimoens
9 Jul 2012, 6:25 AM
This seems to be fixed in Sencha Touch 2