Results 1 to 4 of 4

Thread: Confusing using refs in controller config. When to use advance version?

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Austin, TX
    Posts
    43
    Vote Rating
    0
      0  

    Default Unanswered: Confusing using refs in controller config. When to use advance version?

    I am confused when to use the simple one line refs or the more advanced refs in controller to get access to an xtype page.


    Assume I have a page that shows a menu:

    Code:
    Ext.define('Flo.view.SiteMenu', {
        extend: 'Ext.List',
        xtype: 'sitemenu',
        id: 'site-menu',
        
        requires: [
        ],
        config: {
           ......

    Then in my other views, I have a button which on tap, goes to this siteMenu page. This button lives on multiple pages. Also when this siteMenu page is activated via xtype 'sitemenu' it will respond to "activate". That means In my controller I will be doing a this.getSiteMenu();


    This is from my "Home" controller refs:

    Code:
    Ext.define('MyApp.controller.Home', {
        extend: 'Ext.app.Controller',
    
    
        config: {
    
    
            refs: {
                
    
    
                siteMenuBtn: '#home-sitemenu-btn',
                          
                siteMenu: {           /// <-- use this??
                    xtype: 'sitemenu',
                    selector: 'site-menu',
                    autoCreate: true
                },
                
                siteMenu: 'sitemenu'   //<--- OR  use this??
    When and what is main difference?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1297
      0  

    Default

    You should use the object if you need to use one of the options like autoCreate. If you don't then you can just use the string.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Austin, TX
    Posts
    43
    Vote Rating
    0
      0  

    Default

    Hi Mitchell, yes I 'm aware of that. But when would I need to use the autoCreate one?

    I'm having trouble because some of my controllers need to access the same xtype pages and there seems to be some conflicts. I don't have exact code, but is it normal to have the same refs within different controllers?

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1297
      0  

    Default

    I use autoCreate for my sheet components a lot, it will just create an instance if one is not set on the ref.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

Posting Permissions

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