打开jsp页面 自动触发ext.button的点击效果,如题

ext.button这个js我引到jsp页面上了,在页面中<body onload="addTab();">,调用这个function,但是没有触发ext.button这个按钮的效果,

引入的js代码
Ext.onReady(function(){

var tabss = new Ext.TabPanel({
renderTo:'tabss',
resizetabss:true, // turn on tab resizing
minTabWidth: 115,
tabWidth:135,
enabletabsscroll:true,
height:700,
defaults: {autoScroll:true},
plugins: new Ext.ux.TabCloseMenu()
});

// tab generation code
var index = 0;
while(index < 1){
// alert(index);
addTab();
}
function addTab(){
tabss.add({
title: 'New Tab ' + (++index),
iconCls: 'tabss',
html: ''
+ Ext.example.bogusMarkup,
closable:true
}).show();
}

new Ext.Button({
text: 'Add Tab',
handler: addTab,
iconCls:'new-tab'
}).render(document.body, 'tabss');
});

之前这个方法在其他地方用<div id="tabss">调用过,但是现在需要调用的地方是纯ext的代码,全是javascript,不能有div,没分了,有高手愿意的话,我在此求教!不知道确切解决方法的我们一起讨论下。

<body onloan="addTab()">这样的方法好像是不行的,你完全没必要这样,可以直接在Ext.onReady中实现么,这是我在你代码基础上改的
JS:
Ext.onReady(function(){
var tabss = new Ext.TabPanel({
renderTo:'tabss',
resizetabs:true, // turn on tab resizing
minTabWidth: 115,
tabWidth:135,
enabletabscroll:true,
height:700,
defaults: {autoScroll:true}
//plugins: new Ext.ux.TabCloseMenu()
});
var index = 0;
addTab();
function addTab(){
tabss.add({
title: 'New Tab ' + (++index),
iconCls: 'tabss',
html: ' Ext.example.bogusMarkup',
closable:true
}).show();
}

new Ext.Button({
text: 'Add Tab',
handler: addTab,
iconCls:'new-tab'
}).render(document.body, 'tabss');
});

html:
<body>
<div id="tabss"></div>
</body>
这样完全可以实现的
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-04-15
没明白你什么意思本回答被网友采纳
第2个回答  2011-04-15
不太明白
"方法在其他地方用<div id="tabss">调用过"
将你的<div id="tabss">单独写在一个网页里,再用panel的autoload导入,url指向你含有<div id="tabss">的网页不就能调用使用两次了吗
第3个回答  2011-04-29
new个viewport布局,将tabss放入其中就可以了
相似回答