-
14 Jan 2012 10:57 AM #1
this.parent and this.getParent() always return undefined in initialize
this.parent and this.getParent() always return undefined in initialize
I can't seem to get this.parent or this.getParent() to return anything in initialize. I think this is also causing the up() method to not work in initialize. I could be missing an obvious reason why this doesn't work. If I am, please let me know why this is.
Example code:
Code:Ext.define('Bv.Template', { extend: 'Ext.Container', xtype: 'bvtemplate', cls: 'bvtemplate', layout: "vbox", flex: 1, config: { templateData: {}, items: [ { html: "See Console for Output", style: "height: 50px;" } ] }, initialize: function(config) { this.callParent(); this.on("show", function() { console.log("<<<SHOW EVENT") console.log(this.parent) // This works console.log(this.getParent()) // This works console.log(this.up("component")) // This works }) console.log("<<<INSIDE INITIALIZATION") console.log(this) // this actually contains a parent object console.log(this.parent) // undefined console.log(this.getParent()) // undefined console.log(this.up("component")) // undefined } }); Ext.application({ name: 'Bv', launch: function() { var template = Ext.create("Bv.Template", { scrollable: true, fullscreen: true, templateData: {"test":true} }); console.log("<<<AFTER CREATION") console.log(template.parent) // This works console.log(template.getParent()) // This works console.log(template.up("component")) // This works } });Twitter: lylepratt
-
16 Jan 2012 11:25 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,652
- Vote Rating
- 14
I don't think it can be there during initialize. Not sure exactly what you are trying to do though where you'd need it.
-
16 Jan 2012 12:32 PM #3
I basically have some dynamic panels are customized when initialized based on an attribute of a parent panel. Would be nice if it were possible to access the parents when initializing something.
Twitter: lylepratt
-
16 Jan 2012 2:28 PM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,652
- Vote Rating
- 14
Initialize is really confined to the instance coming up before it is added to a container.
Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.


Reply With Quote