I'm poking around the Magento internals, and within the Widget/Tab rendering hierarchy there's this concept of Shadow Tabs that I'm a little fuzzy on. When you're defining tabs for your form, you can bind it as a shadow tab
protected function _prepareLayout()
{
parent::_prepareLayout();
$this->addTab('bundle_items', array(
'label' => Mage::helper('bundle')->__('Bundle Items'),
'url' => $this->getUrl('*/*/bundles', array('_current' => true)),
'class' => 'ajax',
));
$this->bindShadowTabs('bundle_items', 'customer_options');
}
The bindShadowTabs
method is documents with
/**
* Mark tabs as dependent of each other
* Arbitrary number of tabs can be specified, but at least two
*
* @param string $tabOneId
* @param string $tabTwoId
* @param string $tabNId...
*/
public function bindShadowTabs($tabOneId, $tabTwoId)
The Javascript that leverages the PHP objects looks like
showTabContentImmediately : function(tab) {
this.hideAllTabsContent();
var tabContentElement = $(this.getTabContentElementId(tab));
if (tabContentElement) {
Element.show(tabContentElement);
Element.addClassName(tab, 'active');
// load shadow tabs, if any
if (tab.shadowTabs && tab.shadowTabs.length) {
for (var k in tab.shadowTabs) {
this.loadShadowTab($(tab.shadowTabs[k]));
}
}
if (!Element.hasClassName(tab, 'ajax only')) {
Element.removeClassName(tab, 'notloaded');
}
this.activeTab = tab;
}
if (varienGlobalEvents) {
varienGlobalEvents.fireEvent('showTab', {tab:tab});
}
},
From a basic reading, it's not entirely clear to me what the implications of making one tab "dependent" on another is. Is this a simple "only render the bundle_item
tab if the customer_options
tab is rendered? Or something more?
It seems like it means that whenever any of the tabs that are bound together as shadowTabs is displayed the other tabs in this grop will also be rendered.
so not "only render the bundle_item
tab if the customer_options
tab is rendered" but rather "whenever the bundle_item
tab or the customer_options
tab is rendered, render the other one as well".
not sure I like the metaphor of a shadow though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With