Results 1 to 3 of 3

Thread: Update Label content

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Answers
    3931
    Vote Rating
    1271
      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 @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

  4. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
      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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •