-
-
Save vrkansagara/c9f82d255c809af7f22698e77ca4c473 to your computer and use it in GitHub Desktop.
MAGENTO: Remotely trigger a Varien tab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Varien.Tabs = Class.create(); | |
Varien.Tabs.prototype = { | |
initialize: function(selector) { | |
var self=this; | |
$$(selector+' a').each(this.initTab.bind(this)); | |
}, | |
initTab: function(el) { | |
el.href = 'javascript:void(0)'; | |
if ($(el.parentNode).hasClassName('active')) { | |
this.showContent(el); | |
} | |
el.observe('click', this.showContent.bind(this, el)); | |
}, | |
showContent: function(a) { | |
var li = $(a.parentNode), ul = $(li.parentNode); | |
ul.getElementsBySelector('li').each(function(el){ | |
var contents = $(el.id+'_contents'); | |
if (el==li) { | |
el.addClassName('active'); | |
contents.show(); | |
} else { | |
el.removeClassName('active'); | |
contents.hide(); | |
} | |
}); | |
}, | |
remoteTabs: function(b) { | |
var controlledLink = $$("#"+b+" a")[0]; | |
this.showContent(controlledLink); | |
} | |
} | |
var csTablist = new Varien.Tabs('.tabs'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a onclick="javascript:csTablist.remoteTabs('product_tabs_email');" href="javascript:void(0);">Link</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment