Dojo dijit.layout.TabContainer - how to add class to tab?

给你一囗甜甜゛ 提交于 2020-01-15 09:33:07

问题


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.


回答1:


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/




回答2:


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' );
} );


来源:https://stackoverflow.com/questions/10636360/dojo-dijit-layout-tabcontainer-how-to-add-class-to-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!