aarondrabeck
23 Oct 2011, 10:21 PM
In Sencha 1.0 I frequently would set configuration options at initialization on Extended objects like below. This was extremely helpful because only after initialization would the object be able to call the instantiated instance of itself via var self = this;. However in 2.0 I cannot seem to get this working at all. I see that initComponent was renamed initialize and I have accounted for that. It seems that initialize is called but "Ext.apply(this, { ... })" does not seem to work. Has anyone found a way to do this?
I do not want to assign ID's because these components need to be reusable.
Sencha 1.0 Example
ViewPort = Ext.extend(Ext.Panel, {
initComponent: function () {
var self = this;
Ext.apply(this, {
items: [ {
xtype: 'panel',
layout: 'card',
dockedItems: {
xtype: 'toolbar',
dock: 'top',
title: "Devices",
items: [{
xtype: 'button',
iconMask: true,
iconCls: 'refresh',
handler: function () {
self.UpdateMe();
self.hide();
self.show();
self.aware
}
}]
},
...
Sencha 2.0 fails to work like so:
Ext.define('ViewPort', {
extend: 'Ext.Panel',
initialize: function() {
var self = this;
console.log(self);
Ext.apply(this, {
config: {
items:[ {
xtype: 'toolbar',
docked: 'top',
title: 'Devices',
items: [{
xtype: 'button',
iconMask: true,
iconCls: 'refresh',
handler: function () {
self.UpdateMe();
self.hide();
self.show();
self.aware
}
}]
}]
...
I do not want to assign ID's because these components need to be reusable.
Sencha 1.0 Example
ViewPort = Ext.extend(Ext.Panel, {
initComponent: function () {
var self = this;
Ext.apply(this, {
items: [ {
xtype: 'panel',
layout: 'card',
dockedItems: {
xtype: 'toolbar',
dock: 'top',
title: "Devices",
items: [{
xtype: 'button',
iconMask: true,
iconCls: 'refresh',
handler: function () {
self.UpdateMe();
self.hide();
self.show();
self.aware
}
}]
},
...
Sencha 2.0 fails to work like so:
Ext.define('ViewPort', {
extend: 'Ext.Panel',
initialize: function() {
var self = this;
console.log(self);
Ext.apply(this, {
config: {
items:[ {
xtype: 'toolbar',
docked: 'top',
title: 'Devices',
items: [{
xtype: 'button',
iconMask: true,
iconCls: 'refresh',
handler: function () {
self.UpdateMe();
self.hide();
self.show();
self.aware
}
}]
}]
...