PDA

View Full Version : [CLOSED]Error in Ext.data.Model.load ?



htammen
5 Mar 2011, 5:38 AM
There seems to be an error in the Ext.data.Model.load method. The --> marked line of the source below throws an exception because operation.getRecords() does not return an error.
Reason: My backend returned a 404 error because I had an error in URL mapping at server side.
Because of the exception my failure method where I normally react to such server errors is never called.


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

var operation = Ext.create('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];

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);
}
},

evant
7 Mar 2011, 8:48 PM
This should be fixed in the next release.