Results 1 to 2 of 2

Thread: Proper way to define a property

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    55
    Vote Rating
    0
      0  

    Default 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

  2. I would do this:

    Code:
    Ext.define('MyComponent', {
        extend : 'Ext.Component',
    
        config : {
            foo : 'bar'
        }
    });
    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('Override.Component', {
        override : 'Ext.Component',
    
        config : {
            foo : 'bar'
        }
    });
    That will affect all subclasses of Ext.Component.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    I would do this:

    Code:
    Ext.define('MyComponent', {
        extend : 'Ext.Component',
    
        config : {
            foo : 'bar'
        }
    });
    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('Override.Component', {
        override : 'Ext.Component',
    
        config : {
            foo : 'bar'
        }
    });
    That will affect all subclasses of Ext.Component.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •