-
24 Feb 2012 8:09 AM #1
Unanswered: Confusing using refs in controller config. When to use advance version?
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:
When and what is main difference?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??
-
24 Feb 2012 8:43 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
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 @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.
-
24 Feb 2012 8:46 AM #3
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?
-
24 Feb 2012 9:00 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
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 @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