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 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,556
    Answers
    3931
    Vote Rating
    1272
      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! Checkout the CODE tag!

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

  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,556
    Answers
    3931
    Vote Rating
    1272
      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! 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
  •