开发者

What are Shadow Tabs in Magento's UI Object Hierarchy?

开发者 https://www.devze.com 2023-03-08 20:04 出处:网络
I\'m poking around the Magento internals, andwithin 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 c

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消