PDA

View Full Version : 4.1 b2 possible bug in Ext.data.Model



redraid
16 Feb 2012, 7:02 AM
When i added field with name "default" to model

Ext.define('ExampleModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'model_id', type: 'int' },
{ name: 'default' }
],
idProperty: 'model_id',
proxy: {
type: 'ajax',
api: {
create: '/catalog/attribute/create/',
read: '/catalog/attribute/',
update: '/catalog/attribute/update/',
destroy: '/catalog/attribute/delete/'
},
reader: {
type: 'json',
root: 'data'
}
}
});
i got error

missing variable name

default = fields.get("default"),ext-all-debug.js (line 46224, col 4)


http://*/assets/ext-4.0.7/ext-all-debug.js/eval/seq/22
Line -19149
after trying to load model with this field
Ext.ModelMgr.getModel('ExampleModel').load(1, {callback: function() {console.log(arguments);}});
i got error

TypeError: this.proxy is undefined
http://*/assets/ext-4.1.0-beta-2/ext-all-debug.js
Line 46224

//wbr

mitchellsimoens
16 Feb 2012, 7:42 AM
So you did this and got the error:


Ext.define('ExampleModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'model_id', type: 'int' },
{ name: 'default' }
],
idProperty: 'model_id',
proxy: {
type: 'ajax',
api: {
create: '/catalog/attribute/create/',
read: '/catalog/attribute/',
update: '/catalog/attribute/update/',
destroy: '/catalog/attribute/delete/'
},
reader: {
type: 'json',
root: 'data'
}
}
});

I would think you would as default is a reserved word in JavaScript.

redraid
16 Feb 2012, 8:31 AM
Yes, i miss {name: 'default'} field when copy-paste and clean code, with 4.0.7 no errors

evant
16 Feb 2012, 1:09 PM
This issue is already fixed for b3, thanks for the report.

redraid
17 Feb 2012, 1:23 AM
I should specify that in the 4.1 b2 names of the js control structures can not be field names.

//wbr