-
21 Sep 2012 1:57 PM #1
Unanswered: Add items in Abstract base class and child class
Unanswered: Add items in Abstract base class and child class
I have a base class where I have an item in my config. I aslo have a class that extends off this base class where I want to add additional items. It seems my child class is overriding my item in my base class. How can I get both to exist?
child class:Code:/* * * Abstract Class for all slides (Page_x_x_x) * */ Ext.define('epiduo_ped.view.Page', { extend: 'Ext.Panel', //xtype: 'page', //fullscreen: true, config: { items:[ { xtype:'pleasesee' } ] } , initialize: function(){ me = this; } });
Code:Ext.define('epiduo_ped.view.1-1-1.Page_1-1-1', { extend: 'epiduo_ped.view.Page', xtype: 'page1-1-1', config: { cls:"page1_1_1BG", items:[ { xtype:'hotspot', width:320, height:400, top:200, left:170, id: 'hotspot_page1-1-1_a' }, { xtype:'hotspot', width:320, height:400, top:200, left:533, id: 'hotspot_page1-1-1_b' } ] } });
-
23 Sep 2012 4:27 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
First off people really need to stop doing this:
You aren't doing anything in there so don't have it. If you are going to do something then you need to have this.callParent(); in there so it will call it's superclass' initialize method.Code:initialize: function(){ me = this; }
You are overriding the items and there isn't an easy way to do it. You could use the applyItems method to insert an item (don't forget the callParent call). You can use the onClassExtended method to change the items array.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
9 Jan 2013 12:48 PM #3Sencha Premium Member
- Join Date
- Jun 2012
- Location
- San Jose, California
- Posts
- 62
- Vote Rating
- 0
- Answers
- 1
Hi mitchellsimoens,
ApplyItems will override all the items in the base class. How can I add some items in subclass to one of containers in the superclass? (I only want to plug the items into a place holder in the base class). So there will be multiple subclasses showing different pages.
thanks for any suggestion or advice or comment
-
9 Jan 2013 1:03 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
You always have access to the superclass with using callParent.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
9 Jan 2013 1:15 PM #5Sencha Premium Member
- Join Date
- Jun 2012
- Location
- San Jose, California
- Posts
- 62
- Vote Rating
- 0
- Answers
- 1
I do call callParent(args) in initComponent(). Can you give a short example on how to add items in subclass?
-
9 Jan 2013 1:22 PM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
Sencha Touch doesn't use initComponent (it's been deprecated and you should get a warning in the console).
Code:applyItems: function(newItems, oldItems) { //can do anything here to newItems, oldItems doesn't do anything currently return this.callParent([newItems, oldItems]); }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
9 Jan 2013 2:08 PM #7Sencha Premium Member
- Join Date
- Jun 2012
- Location
- San Jose, California
- Posts
- 62
- Vote Rating
- 0
- Answers
- 1
I am in extjs 4 not sencha tough
-
9 Jan 2013 2:09 PM #8Sencha Premium Member
- Join Date
- Jun 2012
- Location
- San Jose, California
- Posts
- 62
- Vote Rating
- 0
- Answers
- 1
Not Sencha Touch


Reply With Quote