PDA

View Full Version : [4.1 beta 2 ] record.save() is not working ?



dedoz
27 Jan 2012, 7:13 PM
just asking before posting a bug
using a trivial record.save() gives me an error



Ext.onReady(function() {
Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);

Ext.define('someModel', {
extend: 'Ext.data.Model',
fields: ['id','someField'],
proxy:
{ type: 'direct',
api:{ create : carDefaultQuery.carInsert }
}
});


var myRecord = Ext.create('someModel');
myRecord.set('someField','some text');
myRecord.save();

});





error comes from this library code


Ext.define('Ext.data.proxy.Direct', {
..........
doRequest: function(operation, callback, scope) {
var me = this,
writer = me.getWriter(),
request = me.buildRequest(operation, callback, scope),
fn = me.api[request.action] || me.directFn,
params = request.params,
method,
args;

if (!fn) {
Ext.Error.raise('No direct function specified for this proxy');
}
if (operation.allowWrite()) {
request = writer.write(request);
}
if (operation.action == 'read') {
// We need to pass params
method = fn.directCfg.method;
args = method.getArgs(params, me.paramOrder, me.paramsAsHash);
} else {
args.push(request.jsonData); <-- ERROR, args undefined
}
Ext.apply(request, {
args: args,
directFn: fn
});
args.push(me.createRequestCallback(request, operation, callback, scope), me);
fn.apply(window, args);
},
......


if u look at this code, args never was initialized before the args.push that gives the error.

evant
27 Jan 2012, 8:42 PM
You're right, that should initialize the array. Thanks for the report.

dedoz
27 Jan 2012, 9:55 PM
no problem but, to make my own fix while u guys release the beta 3

where should i initialize the array ?
just before the arg.push ? something like args = new Array() ?