I’m having trouble when I try to create a new object in ExtJS. First I create a new object, then create another object of the same class. In that class I have a property, called ‘form’. This property is of type ‘object’. I’ll show below:
Ext.define('ExampleClass', {
extend: 'Ext.Component',
form: {
last: null
},
initComponent: function() {
if(this.form.last == null) {
this.form.last = this;
}
else {
console.log(this.form);
}
this.callParent(arguments);
}
});
The code is simple. When I create the first object, ok. When I create the second object, the console shows the first object (entering the else condition). This only happens when I have an object as a property of the class. This can be a bug of Ext or I really need to clone all objects in the class every time I create a new object?
You need to create your form in
initComponent, since you want a separate instance for eachExampleClassinstance.In your current implementation, there is only one
formobject, sinceExt.defineis called only once. Then on instantiantion a reference to the existing object is passed to the instances.