最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do you test whether a tab is active with dojo tabs - Stack Overflow

programmeradmin2浏览0评论

How do you test whether a tab is active or not with a dojo tab container? (In JQuery this is simple... you can use something like this

if($("#accordion").accordion('option', 'active') == mytabNumber){

With dojo's, dijit.layout.TabContainer there must be a similiar way to do it without having to write a litener function and all that jazz.

perhaps something like...

if( dojo.byId("tab2"), {selected:true} ){

Thanks in advance!

How do you test whether a tab is active or not with a dojo tab container? (In JQuery this is simple... you can use something like this

if($("#accordion").accordion('option', 'active') == mytabNumber){

With dojo's, dijit.layout.TabContainer there must be a similiar way to do it without having to write a litener function and all that jazz.

perhaps something like...

if( dojo.byId("tab2"), {selected:true} ){

Thanks in advance!

Share Improve this question asked Jun 29, 2011 at 21:24 lancelance 531 silver badge9 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

You can pare the widget for the tab with the tab container's selectedChildWidget property, i.e.:

dijit.byId('tabContainer').selectedChildWidget == dijit.byId('tab2')

If you have a reference to the tab already, you can simply just check its 'selected' property to see if it's selected, regardless of the container it is in.

var tab2 = dijit.byId('tab2');
if (tab2.get('selected')) { /* do stuff */ }

I've created a more detailed example at http://jsfiddle/brianarn/ws28T/

Here's more plete code answer that gives the surrounding code for Dojo 1.8:

require(["dijit/registry",  "dojo/ready", "dojo/domReady!"], function (registry, ready) {
    ready(function () { //wait till dom is parsed into dijits
        if (dijit.byId('tabContainer').selectedChildWidget == dijit.byId('tab2'))
            alert('Yes, we found it!');
    });
});
发布评论

评论列表(0)

  1. 暂无评论