我如何“得到” “点击”的ID标签在dijit.layout.tabcontainer? [英] How do I "get" the ID for a "clicked" tab in a dijit.layout.tabcontainer?

查看:142
本文介绍了我如何“得到” “点击”的ID标签在dijit.layout.tabcontainer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有找到一个明确的解决方案。大多数是不完整的片段。

I haven't been able to find a clearly defined solution for this. Most are incomplete snippets.

这是一个简单的示例。请参阅doSomething()注释:

Here is a simple sample. See the doSomething() comment:


<head>
    <style type="text/css">
        body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
    </style>
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css"/>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"
    djConfig="parseOnLoad: true">
    </script>
    <script type="text/javascript">
        dojo.require("dijit.layout.TabContainer");
        dojo.require("dijit.layout.ContentPane");

    function doSomething() {
        //Put code in here that identifies the clicked tab and displays it's id in the below alert
        alert("Hello World!");
    }   

    </script>

</head>

<body class=" claro ">
    <div id="mainTab" dojoType="dijit.layout.TabContainer" style="width: 400px; height: 100px;" onClick="doSomething();">
        <div id="tab1" dojoType="dijit.layout.ContentPane" title="My first tab" selected="true">
            Lorem ipsum and all around...
        </div>
        <div id="tab2" dojoType="dijit.layout.ContentPane" title="My second tab">
            Lorem ipsum and all around - second...
        </div>
        <div id="tab3" dojoType="dijit.layout.ContentPane" title="My last tab">
            Lorem ipsum and all around - last...
        </div>
    </div>
</body>

推荐答案

我相信 dijit.byId('mainTab')。selectedChildWidget 应该提供对所选标签(例如您的一个ContentPanes)中的小部件的引用。

I believe dijit.byId('mainTab').selectedChildWidget ought to give you a reference to the widget in the selected tab (e.g. one of your ContentPanes).

http: //www.dojotoolkit.org/api/dijit/layout/TabContainer.html#selectedChildWidget

这篇关于我如何“得到” “点击”的ID标签在dijit.layout.tabcontainer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆