gpt4 book ai didi

javascript - ExtJs - onReady 是 tab click()

转载 作者:行者123 更新时间:2023-11-28 01:42:11 25 4
gpt4 key购买 nike

具有三个选项卡按钮。 (tab_button_1、tab_button_2、tab_button_3)

tab_page 加载 - 选择 tab_button_1。

但是。

main_page 链接 (tab_button_2)..

jquery 是 $("#tab_button_2").click();extjs ??????

这个试过了。- document.getElementById('tab_button_2').click;- Ext.get('tab_button_2').el.dom.click();- setActiveTab(2);

函数代码(BASE_TABS)

<小时/>
var BASE_TABS = function(itemsDefine){ 
var strItems_Define = "[";

for(var i=0; i < itemsDefine.length; i++) {
strItems_Define += "{";
strItems_Define += "title:'<div style=padding-top:2px>" +itemsDefine[i].title+ "</div>',\n";
strItems_Define += "id: 'tab"+itemsDefine[i].loca+"_" +(i+1)+ "',\n";
strItems_Define += "listeners: {activate: handleActivate},\n";
strItems_Define += "html: getDomObjStr('iframe', 'ifrm"+itemsDefine[i].loca+"_"+(i+1)+"', '"+itemsDefine[i].url+"')";
strItems_Define += "},\n";
}
strItems_Define = strItems_Define.substring(0, strItems_Define.length-2);
strItems_Define += "]";

return eval(strItems_Define);
};

功能代码(G_COMMON_LAYOUT_NCC)

<小时/>
var G_COMMON_LAYOUT_NCC = function(pTabItems1, pTabItems2, pHeight) {
var rHeight =15;

if (pHeight != null)
rHeight = pHeight;

var common_viewport =
new Ext.Viewport({
layout: 'border',
items: [
tabpan1 = new Ext.TabPanel({
region : 'south',
id : 'south-cont-panel1',
activeTab : 0, // first tab initially active
margins : '0 5 5 5',
height : 130,
minSize : 130,
maxSize : 700,
enableTabScroll: true,
defaults : {autoScroll: true},
plugins : new Ext.ux.TabCloseMenu(),
tabPosition : 'top',
split : true,
collapseMode:'mini',
items:pTabItems1
}),
tabpan2 = new Ext.TabPanel({
region : 'center', // a center region is ALWAYS required for border layout
id : 'center-cont-panel2',
split : true,
activeTab : 0, // first tab initially active
margins : '32 5 5 5',
width : 800,
height : 500,
enableTabScroll: true,
defaults : {autoScroll: true},
plugins : new Ext.ux.TabCloseMenu(),
tabPosition : 'top',
items: pTabItems2
})
]
});

return common_viewport;
};

正文

<小时/>
var arryTabs1_Define = [
{loca: 1, title: 'Q-Note List', url: '/doclist/doclistmng/docQnoteListMngSubList.do?mode=<s:property value="#parameters.mode"/>&menu_div=<s:property value="#parameters.menu_div"/>&portalQnoteType=<s:property value="#parameters.portalQnoteType"/>&qnTabType=A'}
,{loca: 1, title: 'My Q-Note List', url: '/doclist/doclistmng/docQnoteListMngSubList.do?mode=<s:property value="#parameters.mode"/>&menu_div=<s:property value="#parameters.menu_div"/>&qnTabType=M'}
,{loca: 1, title: 'Decision Q-Note List', url: '/doclist/doclistmng/docQnoteListMngSubList.do?mode=<s:property value="#parameters.mode"/>&menu_div=<s:property value="#parameters.menu_div"/>&qnTabType=D'}
];

var arryTabs2_Define = [
{loca: 2, title: 'Information', url: '/common/loading.do'}
];

var tabs1 = BASE_TABS(arryTabs1_Define);
var tabs2 = BASE_TABS(arryTabs2_Define);

Ext.onReady(function() { G_COMMON_LAYOUT_NCC(tabs2, tabs1, 120);

//这个点击事件 //tab_button_2});

最佳答案

要使用 Extjs 触发事件,您可以使用:

var myTabPanel = Ext.getCmp('#south-cont-panel1');
myTabPanel.fireEvent('click', myTabPanel);

或者使用纯 JavaScript:

function fireEvent(element, event) {
if ('createEvent' in document) {
var evt = document.createEvent('HTMLEvents');
evt.initEvent(event, false, true);
element.dispatchEvent(evt);
} else {
element.fireEvent('on' + event);
}
}

var btn = document.getElementById('tab_button_2');
fireEvent(btn,'click');

关于javascript - ExtJs - onReady 是 tab click(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20796035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com