var tabs = new Ext.TabPanel({
id:'menufst',
[color=red]region:'center',[/color]
enableTabScroll:true,
resizeTabs:true, // turn on tab resizing
minTabWidth:90,
activeTab:0,
plugins: new Ext.ux.TabCloseMenu(),
items:[{
id:'homePage',
title:'首页',
autoScroll:true,
[color=red]html:"
Ext.onReady(function(){new Ext.Viewport({
id:'vp',
layout:'border',
defaults:{activeItem:0},
items:[{
region:"north",
height:40,
html:'
请问,如何获得m1的操作权?[/color]
把你的代码加到onReady后面去就行了:
[code="javascript"]
Ext.onReady(function(){new Ext.Viewport({
id:'vp',
layout:'border',
defaults:{activeItem:0},
items:[{
region:"north",
height:40,
html:'
这个是因为你调用document.getElementById的时候,m1那个div还没渲染.所以就出错了,可以看Panel的源代码,它是在afterRender方法里才开始进行渲染html的内容的.
[code="js"]
//afterRender里的一段渲染html的源码
if(this.html){
this.body.update(typeof this.html == 'object' ?
Ext.DomHelper.markup(this.html) :
this.html);
delete this.html;
}
[/code]
你可以将你的代码改成下面的就能够得到m1了
[code="js"]
var MyPanel = Ext.extend(Ext.Panel,{
id:'homePage',
title:'首页',
autoScroll:true,
html:"
Ext.onReady(function(){
new Ext.Viewport({
id:'vp',
layout:'border',
defaults:{activeItem:0},
items:[{
region:"north",
height:40,
html:'<div>标题</div>'},
tabs]
});
});
[/code]