-
17 Jan 2012 11:05 AM #1
Answered: Proper way to define a property
Answered: Proper way to define a property
Hello all,
this is a newbie question so bare with me. I want to define a custom property in each and every Panel of a Carousel, or more generally I want to define a custom property in a ST2 component. How would I go about it?
a) simply define it in the component object, inside the Ext.define or
b) extend the component to create my own and in there define the property?
If b) is the correct answer where should I place the component definition?
thx
-
Best Answer Posted by mitchellsimoens
I would do this:
That only works if you are going to use MyComponent, this will not affect existing classes. If you want to affect all components then you should do something like:Code:Ext.define('MyComponent', { extend : 'Ext.Component', config : { foo : 'bar' } });
That will affect all subclasses of Ext.Component.Code:Ext.define('Override.Component', { override : 'Ext.Component', config : { foo : 'bar' } });
-
17 Jan 2012 11:11 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
I would do this:
That only works if you are going to use MyComponent, this will not affect existing classes. If you want to affect all components then you should do something like:Code:Ext.define('MyComponent', { extend : 'Ext.Component', config : { foo : 'bar' } });
That will affect all subclasses of Ext.Component.Code:Ext.define('Override.Component', { override : 'Ext.Component', config : { foo : 'bar' } });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.


Reply With Quote