There is no simple method of hiding and showing a Dijit ContentPane.
If you are displaying a number of ContentPanes within a TabContainer you may need to hide (and possibly redisplay) one or more of the ContentPanes. For instance if the tabs are displaying information based on a selected product/user/etc… some tabs might not be relevant depending on the selected product/user/etc… If you can change the selected product/user/etc… via JavaScript/AJAX, you need to be able to hide and redisplay ContentPanes.
You can remove a ContentPane by calling removeChild on the TabContainer, however if you want to be able to re-display the ContentPane later, you need to save the Dijit widget to a global JavaScript variable before you remove it.
For example assuming your page has this:
[fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][html]
……
[/html]
You can hide MyTab like this:
[/fusion_builder_column][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][javascript]
saveMyTabWidget = dijit.byId(‘MyTab’);
dijit.byId(‘MyTabContainer’).removeChild(dijit.byId(‘MyTab’));
[/javascript]
And then, to redisplay, you’ll want to check if the saveMyTabWidget variable has been set, and if so, add it back as a child to the TabContainer, like this:
[/fusion_builder_column][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][javascript]
if (typeof saveMyTabWidget != “undefined”) {
saveMyTabWidget.setHref(theURL);
dijit.byId(‘MyTabContainer’).addChild(saveMyTabWidget, 0);
saleProductsTabWidget = undefined;
}
[/javascript]
[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
Leave a Reply