ExtJs - onReady是标签点击()

时间:2013-12-27 06:35:10

标签: javascript extjs

有三个标签按钮。 (tab_button_1,tab_button_2,tab_button_3)

tab_page onload - seleted 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 });

1 个答案:

答案 0 :(得分:1)

要使用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');