I have a tab bar:
var tab1 = { id: 'section1', title: 'First Section', padding: 10, html: '(this content will be replaced with an ajax load)' } var tab2 = { id: 'section2', title: 'Second Section', padding: 10, html: '(this content will be replaced with an ajax load)' } var tab3 = { id: 'section3', title: 'Third Section', padding: 10, html: '(this content will be replaced with an ajax load)' } var modules_info_panel = new Ext.TabPanel({ region: 'center', activeTab: 0, border: false, defaults:{autoScroll:true}, items:[tab1, tab2, tab3] });
Then, having created this tab, I would like to dynamically change the contents of the tabs, but none of them work:
tab1.html = 'new html'; // no effect tab1.title = 'new title'; // no effect tab1.update('new text'); // error: tab1.update is not a function viewport.doLayout(); // no effect
Since I want to load the contents of each of the tabs using AJAX , I do not want to dynamically add add tabs as suggested in this question , but you want the tabs to be visible from the first load , and each tab is dynamically changed when you press.
How can I change the contents of a tab after creating it?
Update:
Thanks @Chau for catching my control: when I create tabs with Ext.Panel instead of simple JavaScript object literals, it works:
var tab1 = new Ext.Panel ({ id: 'section1', title: 'First Section', padding: 10, html: '(this content will be replaced with an ajax load)' }); var tab2 = new Ext.Panel ({ id: 'section2', title: 'Second Section', padding: 10, html: '(this content will be replaced with an ajax load)' }); var tab3 = new Ext.Panel ({ id: 'section3', title: 'Third Section', padding: 10, html: '(this content will be replaced with an ajax load)' }); var modules_info_panel = new Ext.TabPanel({ region: 'center', activeTab: 0, border: false, defaults:{autoScroll:true}, items:[tab1, tab2, tab3] }); tab1.update('new content with update');