简体   繁体   中英

Setting html of a component in a panel sencha touch

i searched for my problem there is alot of questions and answers i found but none was useful to me
I have a xtype: 'component', in my panel i want to set dynamically htmlon panel show for it HERE is my component code

{
    xtype: 'component',
    itemId: 'dashboardwelcomenote',
    style: 'text-align: center'
},  

here is my controller

var welcomename = Ext.ComponentQuery.query('#dashboardwelcomenote')[0];
welcomename.setHtml('welcome');  

i want it on panel show any luck for me ?

Instead of itemId you can use reference as follow:

{
        xtype: 'component',
        reference: 'dashboardwelcomenote',
        style: 'text-align: center'
}

Now on panel show or we can say init function of controller ie page load, you can write:

this.lookupReference('dashboardwelcomenote').setHtml('welcome');

Here, "this" is the controller itself.

Hope this helps. Happy Learning :)

尝试更新这里是一个小提琴 .. 文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM