-
18 Oct 2011 2:15 AM #1
Answered: Controller "refs" property - confusion!
Answered: Controller "refs" property - confusion!
Can anyone describe the "refs" property of controller? I am having a image on a container and I want to perform some task on clicking this image. Now I think this is somehow possible by putting the "refs" property in controller but a little more explanation would help.
The "afterrender" event of container is gone and I am not sure how to add a "click" listener to container. I checked the existing examples but still confused about this property.Swarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
Best Answer Posted by TommyMaintz
I would suggest reading the following articles to get more familiar with the MVC structure. this.control and refs have two completely different purposes.
http://www.sencha.com/learn/architec...xt-js-4-part-1
http://www.sencha.com/learn/architec...xt-js-4-part-2
http://www.sencha.com/learn/architec...xt-js-4-part-3
-
18 Oct 2011 6:13 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
you can use the renderedchange event instead of afterrender... the docs will improve before GA...
refs create a reference to a component... basically using Ext.ComponentQuery#down. If you look at the source of the kitchensink Main controller it sets up a few refs.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.
-
18 Oct 2011 6:29 AM #3
Hi Michell,
This is what I am doing:
But that event is never getting fired. Am I doing it right?Code:Ext.create('Ext.Panel', { height : 128, docked : 'top', html : 'Hello', listeners : { scope : this, renderedchange : function(panel, a , b , c){ console.log('Some logs'); } } });Swarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
18 Oct 2011 7:03 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
Looks like it will only do it on the parent...
All it will console out is 'main panel'... not the behavior I would expect IMO...Code:Ext.create('Ext.Panel', { fullscreen : true, layout : 'fit', items : [ { xtype : 'panel', listeners : { renderedchange : function(panel) { console.log('nested panel'); } } } ], listeners : { renderedchange : function(panel) { console.log('main panel'); } } });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.
-
18 Oct 2011 7:44 AM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
- Answers
- 83
IMHO, refs are good when you have a single, static instance of a view. I honestly don't like them. So i use this.control() instead.

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
18 Oct 2011 8:04 AM #6
Yes, I got some idea but some more description of it in doc would help.
@Michell
I added the event "renederedchange" for parent and all the child items - but still I didn't get any of them fired. This is my code:
Code:Ext.define('InvoiceIT.view.Dashboard', { extend : 'Ext.Panel', xtype : 'dashboard', listeners : { scope : this, renderedchange : function(panel, a , b , c){ console.log('Parent') } }, config : { defaults : { xtype : 'container' }, items : [{ height : 128, docked : 'top', listeners : { scope : this, renderedchange : function(panel, a , b , c){ console.log('top'); } } }, { listeners : { scope : this, renderedchange : function(panel, a , b , c){ console.log('center'); } } },{ docked : 'bottom', height : 242, listeners : { scope : this, renderedchange : function(panel, a , b , c){ console.log('bottom'); } } }] } });Swarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
19 Oct 2011 7:11 AM #7Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
- Answers
- 28
I would suggest reading the following articles to get more familiar with the MVC structure. this.control and refs have two completely different purposes.
http://www.sencha.com/learn/architec...xt-js-4-part-1
http://www.sencha.com/learn/architec...xt-js-4-part-2
http://www.sencha.com/learn/architec...xt-js-4-part-3



Reply With Quote
