View Full Version : JavaScript Errors only on iPhone (Simulator)

15 Feb 2011, 3:07 AM
When I test my Sencha App on Google Chrome everything works fine!

But when I test my Sencha App on the iPhone & iPhone Simulator* I get the following errors:

*Edit: On Android, too.

JavaScript Error on Line 7209
TypeError: Result of expression 'records' [undefined] is not an object.

JavaScript Error on Line 5229
TypeError: Result of expression 'operation.getRecords()' [undefined] is not an object.

Clearing the browser cache didn't solve the problem.

I use Sencha Touch Debug 1.0.1a.

18 Feb 2011, 5:42 AM
Sounds like it might be a timing issue. Have you tried to figure out what class is causing the error?

18 Feb 2011, 5:59 AM
Safari Mobile gives me online these two line numbers. I get no errors via Google Chrome, so it's really hard to debug it.

I'll show you some lines of code which are in association with the error:

List having the timeout:

// POI List
app.poiListPanel = new Ext.List({
id : 'poiList',
scroll : 'vertical',
itemTpl : tplItem,
store : stores.pois.load(),
grouped : true,
onItemDisclosure: function(record) {
Ext.ModelMgr.getModel('Pois').load(record.data.id, {
success: function(poi) {


stores.pois = new Ext.data.Store({
model: 'Pois',
sorters: 'title',
getGroupString: function(record) {
var title = record.get('title')[0];
title = title.toUpperCase();
title = title.replace(/\W/g, "");
return title;


Ext.regModel('Pois', {
idProperty: 'id',

fields: [
// ... more

proxy: {
type: 'rest',
url : '/api/pois',
id: 'id',
appendId: true,
headers: {
// ... some specific header params for api


Error in Line 7209:

Ext.data.Store {
loadRecords: function(records, add) {
if (!add) {


for (var i = 0, length = records.length; i < length; i++) { // Line 7209
records[i].needsAdd = false;


if (this.filterOnLoad && !this.remoteFilter) {

if (this.sortOnLoad && !this.remoteSort) {

this.fireEvent('datachanged', this, records);

Error in Line 5229:

Ext.apply(Ext.data.Model, {

setProxy: function(proxy) {

proxy = Ext.data.ProxyMgr.create(proxy);

this.proxy = proxy;

return proxy;

load: function(id, config) {
config = Ext.applyIf(config || {}, {
action: 'read',
id : id

var operation = new Ext.data.Operation(config),
callbackFn = config.callback,
successFn = config.success,
failureFn = config.failure,
scope = config.scope,
record, callback;

callback = function(operation) {
record = operation.getRecords()[0]; // Line 5229

if (operation.wasSuccessful()) {
if (typeof successFn == 'function') {
successFn.call(scope, record, operation);
} else {
if (typeof failureFn == 'function') {
failureFn.call(scope, record, operation);

if (typeof callbackFn == 'function') {
callbackFn.call(scope, record, operation);

this.proxy.read(operation, callback, this);

28 Feb 2011, 2:27 AM
I'm getting this same problem. Could it be because my store is loaded from another domain name?

store_Transactions = new Ext.data.Store({
model : "Transactions",
proxy: {
type: 'ajax',
url : 'http://FOREIGN-DOMAIN.COM/...',
reader: {
type: 'json',
root: 'transactions'
autoLoad: true,

listeners: {
load: function(store, records, success) {
Ext.Msg.alert('Store loaded', 'Transactions loaded', Ext.emptyFn);

28 Feb 2011, 2:28 AM
I forgot to mention that on the iPad there will be no popup, i.e. the Ext.Msg.alert() will never be executed, but on Chrome and Safari everything seems to work fine.

28 Feb 2011, 2:38 AM
If you load your data from a different location you need to use JSONP (JSON Padding). But this has nothing to do with the error for me. I request data from the same location: Everything works fine in Google Chrome and fails on iPhone and Android.

28 Feb 2011, 6:25 PM
Thanks, I tried implementing your changes but I still keep having the same problem. Everything works fine on Chrome/Safari but not on the iPad.

Were you able to find a solution?

1 Mar 2011, 12:11 AM
No I still have no clue on this topic. I hope Sencha Touch will be fixed soon.

31 Aug 2011, 3:55 AM
I had the exact same problem and the same error message.
It turned out to be a configuration problem.

My proxy url prefix was localhost instead of the actual ip address of the server in the local netwrok.

Maybe this is what happens in your case as well...

29 Sep 2011, 5:11 AM
Changed to the latest version of Sencha Touch (1.1.1). But the problem is still the same... my app doesn't work on the iPhone (Safari Mobile).