-
2 Apr 2012 2:12 AM #1
Answered: Update Label content
Answered: Update Label content
Looks easy but I'm completely lost:
Got this view with a label:
And I try to update it from the controller. I have tried both to use the "ref" option and with the getCmp...Code:Ext.define('myApp.view.menuVw', { extend: 'Ext.Container', config: { id:'menuMainView', fullscreen: true, items: [ { xtype: 'label', id:'statusLabel', html: 'Loading...', top: '80%', left:'50%' } ] } });
(option1)
(option2)Code:Ext.getCmp('statusLabel').setHtml('caca');
Code:refs: { statusLabel:'#statusLabel' },
Code:var statLab = this.getStatusLabel(); statLab.setHtml('caca');
In both cases, if a log to console statLab variable I can see that the content has been updated but in the screen the label still shows the original html.
Thanks!Last edited by mitchellsimoens; 2 Apr 2012 at 5:02 AM. Reason: [QUOTE] to [CODE]
-
Best Answer Posted by LeBuFon
Wow, got it, the problem was related to this message
[Ext.Component#constructor] Registering a component with a id (`.....`) which has already been used.
I removed the view from the launch section in the app.js and now it updates!!!
Is the view automatically created when defined in the views section? Is the order of definition the order of appearance?Code:launch: function() { //Ext.create('newapp.view.menuVw'); }
Anyway, thanks a lot!
Code:views: ['menuVw','aboutVw'],
-
2 Apr 2012 5:08 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
With your code, I simply did this:
And it worked for me.Code:var view = new myApp.view.menuVw(), label = view.down('label'); setTimeout(function() { label.setHtml('Mitchell is great!'); }, 1000);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.
-
2 Apr 2012 6:35 AM #3
Wow, got it, the problem was related to this message
[Ext.Component#constructor] Registering a component with a id (`.....`) which has already been used.
I removed the view from the launch section in the app.js and now it updates!!!
Is the view automatically created when defined in the views section? Is the order of definition the order of appearance?Code:launch: function() { //Ext.create('newapp.view.menuVw'); }
Anyway, thanks a lot!
Code:views: ['menuVw','aboutVw'],


Reply With Quote