我有一个这样的标签面板:
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]
});
然后在创建此选项卡面板后,我想动态更改选项卡的内容,但这些都不起作用:
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
由于我想通过AJAX加载每个选项卡的内容,我不想按照此问题中的建议动态添加选项卡,但希望选项卡从第一次加载时可见,并且每个选项卡的内容在单击时动态更改.
选项卡创建后如何更改其内容?
更新:
感谢@Chau 发现我的疏忽:当我使用Ext.Panel
而不是简单的 javascript 对象文字创建选项卡时,它可以工作:
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'); //works