PDA

View Full Version : [NOREPRO] [4.2.1] TypeError: Cannot call method 'hasId' of undefined



plleeuwm
25 Sep 2013, 10:29 AM
REQUIRED INFORMATION

Ext version tested:

Ext 4.2.1
Browser versions tested against:

Chrome
FF
Description:

Model methods are called on a null value.
Steps to reproduce the problem:



Create a model with an association that doesn't have any associated data. Call the associated getter.
Sample code:

Ext.define('Address', {extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'number', type: 'string' },
{ name: 'street', type: 'string' },
{ name: 'city', type: 'string' },
{ name: 'zip', type: 'string' }
],


proxy: 'memory'
});


Ext.define('Person', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' },
{ name: 'address_id', type: 'int'}
],
// we can use the hasOne shortcut on the model to create a hasOne association
associations: [{ type: 'hasOne', model: 'Address' }],


proxy: 'memory'
});


new Person().getAddress();

Gary Schlosberg
25 Sep 2013, 10:51 AM
Thanks for the report! I have opened a bug in our bug tracker.