Dojo dijit.layout.TabContainer - how to add class

2019-08-02 19:44发布

Ho to add class to the tab in TabContainer?

Only thing I've found is set iconClass. However I need to add class to the parent div in tab. Not to some nested divs inside it.

2条回答
We Are One
2楼-- · 2019-08-02 19:56

Not a simple way, but I got access to the tab button in the tabcontainer object.

var tabContainer = ...; 
dojo.addClass(tabContainer.tablist.pane2button["123"].domNode, "myTabClass");

http://jsfiddle.net/cswing/N2hsG/

查看更多
\"骚年 ilove
3楼-- · 2019-08-02 20:13

Building on Craig's suggestion, here's the modern way of doing it:

// assuming there is only one tabContainer on the page it will have an id of 'tab_container'
require( [ 'dijit/registry', 'dojo/dom-class' ], 
    function( registry, domClass )
{
    domClass.add( registry.byId( 'tab_container' ).tablist.pane2button['my_pane_id'].domNode, 'my_css_class' );
} );
查看更多
登录 后发表回答