1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    LeBuFon is on a distinguished road

      0  

    Default Answered: Update Label content

    Answered: Update Label content


    Looks easy but I'm completely lost:

    Got this view with a label:

    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%'
                   }
             ]
       }                  
      });
    And I try to update it from the controller. I have tried both to use the "ref" option and with the getCmp...

    (option1)
    Code:
    Ext.getCmp('statusLabel').setHtml('caca');
    (option2)

    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]

  2. 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!!!
    Code:
    launch: function() {
            //Ext.create('newapp.view.menuVw');
        }
    Is the view automatically created when defined in the views section? Is the order of definition the order of appearance?

    Anyway, thanks a lot!

    Code:
     views: ['menuVw','aboutVw'],
    Quote Originally Posted by mitchellsimoens View Post
    With your code, I simply did this:

    Code:
    var view = new myApp.view.menuVw(),
        label = view.down('label');
    
    setTimeout(function() {
        label.setHtml('Mitchell is great!');
    }, 1000);
    And it worked for me.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,047
    Answers
    3495
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    With your code, I simply did this:

    Code:
    var view = new myApp.view.menuVw(),
        label = view.down('label');
    
    setTimeout(function() {
        label.setHtml('Mitchell is great!');
    }, 1000);
    And it worked for me.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  4. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    LeBuFon is on a distinguished road

      0  

    Default


    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!!!
    Code:
    launch: function() {
            //Ext.create('newapp.view.menuVw');
        }
    Is the view automatically created when defined in the views section? Is the order of definition the order of appearance?

    Anyway, thanks a lot!

    Code:
     views: ['menuVw','aboutVw'],
    Quote Originally Posted by mitchellsimoens View Post
    With your code, I simply did this:

    Code:
    var view = new myApp.view.menuVw(),
        label = view.down('label');
    
    setTimeout(function() {
        label.setHtml('Mitchell is great!');
    }, 1000);
    And it worked for me.

Thread Participants: 1

Tags for this Thread